2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * library for displaying table with results from all sort of select queries
13 require_once './libraries/Table.class.php';
14 require_once './libraries/Index.class.php';
17 * Defines the display mode to use for the results of a SQL query
19 * It uses a synthetic string that contains all the required informations.
21 * - the first two characters stand for the action to do while
22 * clicking on the "edit" link (e.g. 'ur' for update a row, 'nn' for no
24 * - the next two characters stand for the action to do while
25 * clicking on the "delete" link (e.g. 'kp' for kill a process, 'nn' for
27 * - the next characters are boolean values (1/0) and respectively stand
28 * for sorting links, navigation bar, "insert a new row" link, the
29 * bookmark feature, the expand/collapse text/blob fields button and
30 * the "display printable view" option.
31 * Of course '0'/'1' means the feature won't/will be enabled.
33 * @param string the synthetic value for display_mode (see a few
34 * lines above for explanations)
35 * @param integer the total number of rows returned by the SQL query
36 * without any programmatically appended "LIMIT" clause
37 * (just a copy of $unlim_num_rows if it exists, else
38 * computed inside this function)
40 * @return array an array with explicit indexes for all the display
43 * @global string the database name
44 * @global string the table name
45 * @global integer the total number of rows returned by the SQL query
46 * without any programmatically appended "LIMIT" clause
47 * @global array the properties of the fields returned by the query
48 * @global string the URL to return to in case of error in a SQL
53 * @see PMA_displayTable()
55 function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
58 global $unlim_num_rows, $fields_meta;
61 // 1. Initializes the $do_display array
62 $do_display = array();
63 $do_display['edit_lnk'] = $the_disp_mode[0] . $the_disp_mode[1];
64 $do_display['del_lnk'] = $the_disp_mode[2] . $the_disp_mode[3];
65 $do_display['sort_lnk'] = (string) $the_disp_mode[4];
66 $do_display['nav_bar'] = (string) $the_disp_mode[5];
67 $do_display['ins_row'] = (string) $the_disp_mode[6];
68 $do_display['bkm_form'] = (string) $the_disp_mode[7];
69 $do_display['text_btn'] = (string) $the_disp_mode[8];
70 $do_display['pview_lnk'] = (string) $the_disp_mode[9];
72 // 2. Display mode is not "false for all elements" -> updates the
74 if ($the_disp_mode != 'nnnn000000') {
75 // 2.0 Print view -> set all elements to false!
76 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
77 $do_display['edit_lnk'] = 'nn'; // no edit link
78 $do_display['del_lnk'] = 'nn'; // no delete link
79 $do_display['sort_lnk'] = (string) '0';
80 $do_display['nav_bar'] = (string) '0';
81 $do_display['ins_row'] = (string) '0';
82 $do_display['bkm_form'] = (string) '0';
83 $do_display['text_btn'] = (string) '0';
84 $do_display['pview_lnk'] = (string) '0';
86 // 2.1 Statement is a "SELECT COUNT", a
87 // "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
88 // contains a "PROC ANALYSE" part
89 elseif ($GLOBALS['is_count'] ||
$GLOBALS['is_analyse'] ||
$GLOBALS['is_maint'] ||
$GLOBALS['is_explain']) {
90 $do_display['edit_lnk'] = 'nn'; // no edit link
91 $do_display['del_lnk'] = 'nn'; // no delete link
92 $do_display['sort_lnk'] = (string) '0';
93 $do_display['nav_bar'] = (string) '0';
94 $do_display['ins_row'] = (string) '0';
95 $do_display['bkm_form'] = (string) '1';
96 if ($GLOBALS['is_maint']) {
97 $do_display['text_btn'] = (string) '1';
99 $do_display['text_btn'] = (string) '0';
101 $do_display['pview_lnk'] = (string) '1';
103 // 2.2 Statement is a "SHOW..."
104 elseif ($GLOBALS['is_show']) {
107 * @todo defines edit/delete links depending on show statement
109 $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which);
110 if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
111 $do_display['edit_lnk'] = 'nn'; // no edit link
112 $do_display['del_lnk'] = 'kp'; // "kill process" type edit link
114 // Default case -> no links
115 $do_display['edit_lnk'] = 'nn'; // no edit link
116 $do_display['del_lnk'] = 'nn'; // no delete link
118 // 2.2.2 Other settings
119 $do_display['sort_lnk'] = (string) '0';
120 $do_display['nav_bar'] = (string) '0';
121 $do_display['ins_row'] = (string) '0';
122 $do_display['bkm_form'] = (string) '1';
123 $do_display['text_btn'] = (string) '1';
124 $do_display['pview_lnk'] = (string) '1';
126 // 2.3 Other statements (ie "SELECT" ones) -> updates
127 // $do_display['edit_lnk'], $do_display['del_lnk'] and
128 // $do_display['text_btn'] (keeps other default values)
130 $prev_table = $fields_meta[0]->table
;
131 $do_display['text_btn'] = (string) '1';
132 for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++
) {
133 $is_link = ($do_display['edit_lnk'] != 'nn'
134 ||
$do_display['del_lnk'] != 'nn'
135 ||
$do_display['sort_lnk'] != '0'
136 ||
$do_display['ins_row'] != '0');
137 // 2.3.2 Displays edit/delete/sort/insert links?
139 && ($fields_meta[$i]->table
== '' ||
$fields_meta[$i]->table
!= $prev_table)) {
140 $do_display['edit_lnk'] = 'nn'; // don't display links
141 $do_display['del_lnk'] = 'nn';
143 * @todo May be problematic with same fields names in two joined table.
145 // $do_display['sort_lnk'] = (string) '0';
146 $do_display['ins_row'] = (string) '0';
147 if ($do_display['text_btn'] == '1') {
151 // 2.3.3 Always display print view link
152 $do_display['pview_lnk'] = (string) '1';
153 $prev_table = $fields_meta[$i]->table
;
155 } // end if..elseif...else (2.1 -> 2.3)
158 // 3. Gets the total number of rows if it is unknown
159 if (isset($unlim_num_rows) && $unlim_num_rows != '') {
160 $the_total = $unlim_num_rows;
161 } elseif (($do_display['nav_bar'] == '1' ||
$do_display['sort_lnk'] == '1')
162 && (strlen($db) && !empty($table))) {
163 $the_total = PMA_Table
::countRecords($db, $table);
166 // 4. If navigation bar or sorting fields names URLs should be
167 // displayed but there is only one row, change these settings to
169 if ($do_display['nav_bar'] == '1' ||
$do_display['sort_lnk'] == '1') {
171 // - Do not display sort links if less than 2 rows.
172 // - For a VIEW we (probably) did not count the number of rows
173 // so don't test this number here, it would remove the possibility
174 // of sorting VIEW results.
175 if (isset($unlim_num_rows) && $unlim_num_rows < 2 && ! PMA_Table
::isView($db, $table)) {
176 // garvin: force display of navbar for vertical/horizontal display-choice.
177 // $do_display['nav_bar'] = (string) '0';
178 $do_display['sort_lnk'] = (string) '0';
182 // 5. Updates the synthetic var
183 $the_disp_mode = join('', $do_display);
186 } // end of the 'PMA_setDisplayMode()' function
190 * Displays a navigation button
192 * @uses $GLOBALS['cfg']['NavigationBarIconic']
193 * @uses PMA_generate_common_hidden_inputs()
195 * @param string iconic caption for button
196 * @param string text for button
197 * @param integer position for next query
198 * @param string query ready for display
199 * @param string optional onsubmit clause
200 * @param string optional hidden field for special treatment
201 * @param string optional onclick clause
203 * @global string $db the database name
204 * @global string $table the table name
205 * @global string $goto the URL to go back in case of errors
209 * @see PMA_displayTableNavigation()
211 function PMA_displayTableNavigationOneButton($caption, $title, $pos, $html_sql_query, $onsubmit = '', $input_for_real_end = '', $onclick = '') {
213 global $db, $table, $goto;
215 $caption_output = '';
216 // for true or 'both'
217 if ($GLOBALS['cfg']['NavigationBarIconic']) {
218 $caption_output .= $caption;
220 // for false or 'both'
221 if (false === $GLOBALS['cfg']['NavigationBarIconic'] ||
'both' === $GLOBALS['cfg']['NavigationBarIconic']) {
222 $caption_output .= ' ' . $title;
224 $title_output = ' title="' . $title . '"';
227 <form action
="sql.php" method
="post" <?php
echo $onsubmit; ?
>>
228 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
229 <input type
="hidden" name
="sql_query" value
="<?php echo $html_sql_query; ?>" />
230 <input type
="hidden" name
="pos" value
="<?php echo $pos; ?>" />
231 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
232 <?php
echo $input_for_real_end; ?
>
233 <input type
="submit" name
="navig" value
="<?php echo $caption_output; ?>"<?php
echo $title_output . $onclick; ?
> />
237 } // end function PMA_displayTableNavigationOneButton()
240 * Displays a navigation bar to browse among the results of a SQL query
242 * @uses $_SESSION['tmp_user_values']['disp_direction']
243 * @uses $_SESSION['tmp_user_values']['repeat_cells']
244 * @uses $_SESSION['tmp_user_values']['max_rows']
245 * @uses $_SESSION['tmp_user_values']['pos']
246 * @param integer the offset for the "next" page
247 * @param integer the offset for the "previous" page
248 * @param string the URL-encoded query
249 * @param string the id for the direction dropdown
251 * @global string $db the database name
252 * @global string $table the table name
253 * @global string $goto the URL to go back in case of errors
254 * @global integer $num_rows the total number of rows returned by the
256 * @global integer $unlim_num_rows the total number of rows returned by the
257 * SQL any programmatically appended "LIMIT" clause
258 * @global boolean $is_innodb whether its InnoDB or not
259 * @global array $showtable table definitions
263 * @see PMA_displayTable()
265 function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_direction_dropdown)
267 global $db, $table, $goto;
268 global $num_rows, $unlim_num_rows;
272 // here, using htmlentities() would cause problems if the query
273 // contains accented characters
274 $html_sql_query = htmlspecialchars($sql_query);
277 * @todo move this to a central place
278 * @todo for other future table types
280 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
284 <!-- Navigation bar
-->
285 <table border
="0" cellpadding
="2" cellspacing
="0">
288 // Move to the beginning or to the previous page
289 if ($_SESSION['tmp_user_values']['pos'] && $_SESSION['tmp_user_values']['max_rows'] != 'all') {
290 PMA_displayTableNavigationOneButton('<<', $GLOBALS['strPos1'], 0, $html_sql_query);
291 PMA_displayTableNavigationOneButton('<', $GLOBALS['strPrevious'], $pos_prev, $html_sql_query);
299 <?php
// if displaying a VIEW, $unlim_num_rows could be zero because
300 // of $cfg['MaxExactCountViews']; in this case, avoid passing
301 // the 5th parameter to checkFormElementInRange()
302 // (this means we can't validate the upper limit ?>
303 <form action
="sql.php" method
="post"
304 onsubmit
="return (checkFormElementInRange(this, 'session_max_rows', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 1) && checkFormElementInRange(this, 'pos', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 0<?php echo $unlim_num_rows > 0 ? ',' . $unlim_num_rows - 1 : ''; ?>))">
305 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
306 <input type
="hidden" name
="sql_query" value
="<?php echo $html_sql_query; ?>" />
307 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
308 <input type
="submit" name
="navig" value
="<?php echo $GLOBALS['strShow']; ?> :" />
309 <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()" />
310 <?php
echo $GLOBALS['strRowsFrom'] . "\n"; ?
>
311 <input type
="text" name
="pos" size
="6" value
="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus
="this.select()" />
314 // Display mode (horizontal/vertical and repeat headers)
316 'horizontal' => $GLOBALS['strRowsModeHorizontal'],
317 'horizontalflipped' => $GLOBALS['strRowsModeFlippedHorizontal'],
318 'vertical' => $GLOBALS['strRowsModeVertical']);
319 $param1 = PMA_generate_html_dropdown('disp_direction', $choices, $_SESSION['tmp_user_values']['disp_direction'], $id_for_direction_dropdown);
322 $param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $_SESSION['tmp_user_values']['repeat_cells'] . '" class="textfield" />' . "\n"
324 echo ' ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
332 // Move to the next page or to the last one
333 if (($_SESSION['tmp_user_values']['pos'] +
$_SESSION['tmp_user_values']['max_rows'] < $unlim_num_rows) && $num_rows >= $_SESSION['tmp_user_values']['max_rows']
334 && $_SESSION['tmp_user_values']['max_rows'] != 'all') {
336 // display the Next button
337 PMA_displayTableNavigationOneButton('>',
342 // prepare some options for the End button
343 if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
344 $input_for_real_end = '<input type="hidden" name="find_real_end" value="1" />';
345 // no backquote around this message
346 $onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], false) . '\')"';
348 $input_for_real_end = $onclick = '';
351 // display the End button
352 PMA_displayTableNavigationOneButton('>>',
354 @((ceil($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows'])- 1) * $_SESSION['tmp_user_values']['max_rows']),
356 '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') . '"',
364 // (unless we are showing all records)
365 if ('all' != $_SESSION['tmp_user_values']['max_rows']) { //if1
366 $pageNow = @floor
($_SESSION['tmp_user_values']['pos'] / $_SESSION['tmp_user_values']['max_rows']) +
1;
367 $nbTotalPage = @ceil
($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows']);
369 if ($nbTotalPage > 1){ //if2
375 <?php
//<form> for keep the form alignment of button < and << ?>
378 $_url_params = array(
381 'sql_query' => $sql_query,
384 echo PMA_pageselector(
385 'sql.php' . PMA_generate_common_url($_url_params) . PMA_get_arg_separator('js'),
386 $_SESSION['tmp_user_values']['max_rows'],
394 $GLOBALS['strPageNumber']
403 // Display the "Show all" button if allowed
404 if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
411 <form action
="sql.php" method
="post">
412 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
413 <input type
="hidden" name
="sql_query" value
="<?php echo $html_sql_query; ?>" />
414 <input type
="hidden" name
="pos" value
="0" />
415 <input type
="hidden" name
="session_max_rows" value
="all" />
416 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
417 <input type
="submit" name
="navig" value
="<?php echo $GLOBALS['strShowAll']; ?>" />
428 } // end of the 'PMA_displayTableNavigation()' function
432 * Displays the headers of the results table
434 * @uses $_SESSION['tmp_user_values']['disp_direction']
435 * @uses $_SESSION['tmp_user_values']['repeat_cells']
436 * @uses $_SESSION['tmp_user_values']['max_rows']
437 * @uses $_SESSION['tmp_user_values']['display_text']
438 * @uses $_SESSION['tmp_user_values']['display_binary']
439 * @uses $_SESSION['tmp_user_values']['display_binary_as_hex']
440 * @param array which elements to display
441 * @param array the list of fields properties
442 * @param integer the total number of fields returned by the SQL query
443 * @param array the analyzed query
445 * @return boolean $clause_is_unique
447 * @global string $db the database name
448 * @global string $table the table name
449 * @global string $goto the URL to go back in case of errors
450 * @global string $sql_query the SQL query
451 * @global integer $num_rows the total number of rows returned by the
453 * @global array $vertical_display informations used with vertical display
458 * @see PMA_displayTable()
460 function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '', $sort_expression, $sort_expression_nodirection, $sort_direction)
462 global $db, $table, $goto;
463 global $sql_query, $num_rows;
464 global $vertical_display, $highlight_columns;
466 if ($analyzed_sql == '') {
467 $analyzed_sql = array();
470 // can the result be sorted?
471 if ($is_display['sort_lnk'] == '1') {
474 $unsorted_sql_query = $sql_query;
475 if (isset($analyzed_sql[0]['unsorted_query'])) {
476 $unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
478 // Handles the case of multiple clicks on a column's header
479 // which would add many spaces before "ORDER BY" in the
481 $unsorted_sql_query = trim($unsorted_sql_query);
483 // sorting by indexes, only if it makes sense (only one table ref)
484 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
485 isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
486 isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
488 // grab indexes data:
489 $indexes = PMA_Index
::getFromTable($table, $db);
491 // do we have any index?
494 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
495 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
497 if ($is_display['edit_lnk'] != 'nn') {
500 if ($is_display['del_lnk'] != 'nn') {
503 if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
507 $span = $num_rows +
floor($num_rows/$_SESSION['tmp_user_values']['repeat_cells']) +
1;
510 echo '<form action="sql.php" method="post">' . "\n";
511 echo PMA_generate_common_hidden_inputs($db, $table);
512 echo $GLOBALS['strSortByKey'] . ': <select name="sql_query" onchange="this.form.submit();">' . "\n";
514 $local_order = (isset($sort_expression) ?
$sort_expression : '');
515 foreach ($indexes as $index) {
516 $asc_sort = '`' . implode('` ASC, `', array_keys($index->getColumns())) . '` ASC';
517 $desc_sort = '`' . implode('` DESC, `', array_keys($index->getColumns())) . '` DESC';
518 $used_index = $used_index ||
$local_order == $asc_sort ||
$local_order == $desc_sort;
519 echo '<option value="'
520 . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $asc_sort)
521 . '"' . ($local_order == $asc_sort ?
' selected="selected"' : '')
522 . '>' . htmlspecialchars($index->getName()) . ' ('
523 . $GLOBALS['strAscending'] . ')</option>';
524 echo '<option value="'
525 . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort)
526 . '"' . ($local_order == $desc_sort ?
' selected="selected"' : '')
527 . '>' . htmlspecialchars($index->getName()) . ' ('
528 . $GLOBALS['strDescending'] . ')</option>';
530 echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ?
'' : ' selected="selected"') . '>' . $GLOBALS['strNone'] . '</option>';
531 echo '</select>' . "\n";
532 echo '<noscript><input type="submit" value="' . $GLOBALS['strGo'] . '" /></noscript>';
533 echo '</form>' . "\n";
539 $vertical_display['emptypre'] = 0;
540 $vertical_display['emptyafter'] = 0;
541 $vertical_display['textbtn'] = '';
543 // Display options (if we are not in print view)
544 if (! (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1')) {
545 echo '<form method="post" action="sql.php" name="displayOptionsForm" id="displayOptionsForm">';
549 'sql_query' => $sql_query,
551 'display_options_form' => 1
553 echo PMA_generate_common_hidden_inputs($url_params);
555 PMA_generate_slider_effect('displayoptions',$GLOBALS['strOptions']);
558 echo '<div class="formelement">';
560 'P' => $GLOBALS['strPartialText'],
561 'F' => $GLOBALS['strFullText']
563 PMA_display_html_radio('display_text', $choices, $_SESSION['tmp_user_values']['display_text']);
566 // prepare full/partial text button or link
567 if ($_SESSION['tmp_user_values']['display_text']=='F') {
568 // currently in fulltext mode so show the opposite link
569 $tmp_image_file = $GLOBALS['pmaThemeImage'] . 's_partialtext.png';
570 $tmp_txt = $GLOBALS['strPartialText'];
571 $url_params['display_text'] = 'P';
573 $tmp_image_file = $GLOBALS['pmaThemeImage'] . 's_fulltext.png';
574 $tmp_txt = $GLOBALS['strFullText'];
575 $url_params['display_text'] = 'F';
578 $tmp_image = '<img class="fulltext" width="50" height="20" src="' . $tmp_image_file . '" alt="' . $tmp_txt . '" title="' . $tmp_txt . '" />';
579 $tmp_url = 'sql.php' . PMA_generate_common_url($url_params);
580 $full_or_partial_text_link = PMA_linkOrButton($tmp_url, $tmp_image, array(), false);
581 unset($tmp_image_file, $tmp_txt, $tmp_url, $tmp_image);
584 if ($GLOBALS['cfgRelation']['relwork'] && $GLOBALS['cfgRelation']['displaywork']) {
585 echo '<div class="formelement">';
587 'K' => $GLOBALS['strRelationalKey'],
588 'D' => $GLOBALS['strRelationalDisplayField']
590 PMA_display_html_radio('relational_display', $choices, $_SESSION['tmp_user_values']['relational_display']);
594 echo '<div class="formelement">';
595 PMA_display_html_checkbox('display_binary', $GLOBALS['strShowBinaryContents'], ! empty($_SESSION['tmp_user_values']['display_binary']), false);
597 PMA_display_html_checkbox('display_blob', $GLOBALS['strShowBLOBContents'], ! empty($_SESSION['tmp_user_values']['display_blob']), false);
599 PMA_display_html_checkbox('display_binary_as_hex', $GLOBALS['strShowBinaryContentsAsHex'], ! empty($_SESSION['tmp_user_values']['display_binary_as_hex']), false);
602 // I would have preferred to name this "display_transformation".
603 // This is the only way I found to be able to keep this setting sticky
604 // per SQL query, and at the same time have a default that displays
605 // the transformations.
606 echo '<div class="formelement">';
607 PMA_display_html_checkbox('hide_transformation', $GLOBALS['strHide'] . ' ' . $GLOBALS['strMIME_transformation'], ! empty($_SESSION['tmp_user_values']['hide_transformation']), false);
610 echo '<div class="clearfloat"></div>';
613 echo '<fieldset class="tblFooters">';
614 echo '<input type="submit" value="' . $GLOBALS['strGo'] . '" />';
620 // Start of form for multi-rows edit/delete/export
622 if ($is_display['del_lnk'] == 'dr' ||
$is_display['del_lnk'] == 'kp') {
623 echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
624 echo PMA_generate_common_hidden_inputs($db, $table, 1);
625 echo '<input type="hidden" name="goto" value="sql.php" />' . "\n";
628 echo '<table id="table_results" class="data">' . "\n";
629 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
630 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
631 echo '<thead><tr>' . "\n";
634 // 1. Displays the full/partial text button (part 1)...
635 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
636 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
637 $colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
641 $rowspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
646 // ... before the result table
647 if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
648 && $is_display['text_btn'] == '1') {
649 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
3 : 0;
650 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
651 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
653 <th colspan
="<?php echo $fields_cnt; ?>"></th
>
657 } // end horizontal/horizontalflipped mode
661 <th colspan
="<?php echo $num_rows + floor($num_rows/$_SESSION['tmp_user_values']['repeat_cells']) + 1; ?>"></th
>
664 } // end vertical mode
667 // ... at the left column of the result table header if possible
669 elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
670 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
3 : 0;
671 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
672 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
674 <th
<?php
echo $colspan; ?
>><?php
echo $full_or_partial_text_link;?
></th
>
676 } // end horizontal/horizontalflipped mode
678 $vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
681 } // end vertical mode
684 // ... elseif no button, displays empty(ies) col(s) if required
685 elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft']
686 && ($is_display['edit_lnk'] != 'nn' ||
$is_display['del_lnk'] != 'nn')) {
687 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
3 : 0;
688 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
689 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
691 <td
<?php
echo $colspan; ?
>></td
>
693 } // end horizontal/horizontalfipped mode
695 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
696 } // end vertical mode
699 // 2. Displays the fields' name
700 // 2.0 If sorting links should be used, checks if the query is a "JOIN"
701 // statement (see 2.1.3)
703 // 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
704 // Do not show comments, if using horizontalflipped mode, because of space usage
705 if ($GLOBALS['cfg']['ShowBrowseComments']
706 && $_SESSION['tmp_user_values']['disp_direction'] != 'horizontalflipped') {
707 $comments_map = array();
708 if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
709 foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
710 $tb = $tbl['table_true_name'];
711 $comments_map[$tb] = PMA_getComments($db, $tb);
717 if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME'] && ! $_SESSION['tmp_user_values']['hide_transformation']) {
718 require_once './libraries/transformations.lib.php';
719 $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
722 if ($is_display['sort_lnk'] == '1') {
723 $select_expr = $analyzed_sql[0]['select_expr_clause'];
726 // garvin: See if we have to highlight any header fields of a WHERE query.
727 // Uses SQL-Parser results.
728 $highlight_columns = array();
729 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
730 isset($analyzed_sql[0]['where_clause_identifiers'])) {
733 if (isset($analyzed_sql[0]['where_clause_identifiers']) && is_array($analyzed_sql[0]['where_clause_identifiers'])) {
734 foreach ($analyzed_sql[0]['where_clause_identifiers'] AS $wci_nr => $wci) {
735 $highlight_columns[$wci] = 'true';
740 for ($i = 0; $i < $fields_cnt; $i++
) {
741 // garvin: See if this column should get highlight because it's used in the
743 if (isset($highlight_columns[$fields_meta[$i]->name
]) ||
isset($highlight_columns[PMA_backquote($fields_meta[$i]->name
)])) {
744 $condition_field = true;
746 $condition_field = false;
749 // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
750 if (isset($comments_map) &&
751 isset($comments_map[$fields_meta[$i]->table
]) &&
752 isset($comments_map[$fields_meta[$i]->table
][$fields_meta[$i]->name
])) {
753 $comments = '<span class="tblcomment">' . htmlspecialchars($comments_map[$fields_meta[$i]->table
][$fields_meta[$i]->name
]) . '</span>';
758 // 2.1 Results can be sorted
759 if ($is_display['sort_lnk'] == '1') {
761 // 2.1.1 Checks if the table name is required; it's the case
762 // for a query with a "JOIN" statement and if the column
763 // isn't aliased, or in queries like
764 // SELECT `1`.`master_field` , `2`.`master_field`
765 // FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
767 if (isset($fields_meta[$i]->table
) && strlen($fields_meta[$i]->table
)) {
768 $sort_tbl = PMA_backquote($fields_meta[$i]->table
) . '.';
773 // 2.1.2 Checks if the current column is used to sort the
775 // the orgname member does not exist for all MySQL versions
776 // but if found, it's the one on which to sort
777 $name_to_use_in_sort = $fields_meta[$i]->name
;
778 if (isset($fields_meta[$i]->orgname
) && strlen($fields_meta[$i]->orgname
)) {
779 $name_to_use_in_sort = $fields_meta[$i]->orgname
;
781 // $name_to_use_in_sort might contain a space due to
782 // formatting of function expressions like "COUNT(name )"
783 // so we remove the space in this situation
784 $name_to_use_in_sort = str_replace(' )', ')', $name_to_use_in_sort);
786 if (empty($sort_expression)) {
789 // Field name may be preceded by a space, or any number
790 // of characters followed by a dot (tablename.fieldname)
791 // so do a direct comparison for the sort expression;
792 // this avoids problems with queries like
793 // "SELECT id, count(id)..." and clicking to sort
794 // on id or on count(id).
795 // Another query to test this:
796 // SELECT p.*, FROM_UNIXTIME(p.temps) FROM mytable AS p
797 // (and try clicking on each column's header twice)
798 if (! empty($sort_tbl) && strpos($sort_expression_nodirection, $sort_tbl) === false && strpos($sort_expression_nodirection, '(') === false) {
799 $sort_expression_nodirection = $sort_tbl . $sort_expression_nodirection;
801 $is_in_sort = (str_replace('`', '', $sort_tbl) . $name_to_use_in_sort == str_replace('`', '', $sort_expression_nodirection) ?
true : false);
803 // 2.1.3 Check the field name for a bracket.
804 // If it contains one, it's probably a function column
805 // like 'COUNT(`field`)'
806 if (strpos($name_to_use_in_sort, '(') !== false) {
807 $sort_order = ' ORDER BY ' . $name_to_use_in_sort . ' ';
809 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($name_to_use_in_sort) . ' ';
811 unset($name_to_use_in_sort);
813 // 2.1.4 Do define the sorting URL
815 // loic1: patch #455484 ("Smart" order)
816 $GLOBALS['cfg']['Order'] = strtoupper($GLOBALS['cfg']['Order']);
817 if ($GLOBALS['cfg']['Order'] === 'SMART') {
818 $sort_order .= (preg_match('@time|date@i', $fields_meta[$i]->type
)) ?
'DESC' : 'ASC';
820 $sort_order .= $GLOBALS['cfg']['Order'];
823 } elseif ('DESC' == $sort_direction) {
824 $sort_order .= ' ASC';
825 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="'. $GLOBALS['strDescending'] . '" title="'. $GLOBALS['strDescending'] . '" id="soimg' . $i . '" />';
827 $sort_order .= ' DESC';
828 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
831 if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3)) {
832 $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
834 $sorted_sql_query = $unsorted_sql_query . $sort_order;
836 $_url_params = array(
839 'sql_query' => $sorted_sql_query,
841 $order_url = 'sql.php' . PMA_generate_common_url($_url_params);
843 // 2.1.5 Displays the sorting URL
844 // added 20004-06-09: Michael Keck <mail@michaelkeck.de>
845 // enable sort order swapping for image
846 $order_link_params = array();
847 if (isset($order_img) && $order_img!='') {
848 if (strstr($order_img, 'asc')) {
849 $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
850 $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
851 } elseif (strstr($order_img, 'desc')) {
852 $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
853 $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
856 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'
857 && $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
858 $order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;';
860 $order_link_params['title'] = $GLOBALS['strSort'];
861 $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
));
862 $order_link = PMA_linkOrButton($order_url, $order_link_content . $order_img, $order_link_params, false, true);
864 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
865 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
867 if ($condition_field) {
868 echo ' class="condition"';
870 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
871 echo ' valign="bottom"';
873 echo '>' . $order_link . $comments . '</th>';
875 $vertical_display['desc'][] = ' <th '
876 . ($condition_field ?
' class="condition"' : '') . '>' . "\n"
877 . $order_link . $comments . ' </th>' . "\n";
880 // 2.2 Results can't be sorted
882 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
883 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
885 if ($condition_field) {
886 echo ' class="condition"';
888 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
889 echo ' valign="bottom"';
891 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'
892 && $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
893 echo ' style="direction: ltr; writing-mode: tb-rl;"';
896 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'
897 && $GLOBALS['cfg']['HeaderFlipType'] == 'fake') {
898 echo PMA_flipstring(htmlspecialchars($fields_meta[$i]->name
), '<br />');
900 echo htmlspecialchars($fields_meta[$i]->name
);
902 echo "\n" . $comments . '</th>';
904 $vertical_display['desc'][] = ' <th '
905 . ($condition_field ?
' class="condition"' : '') . '>' . "\n"
906 . ' ' . htmlspecialchars($fields_meta[$i]->name
) . "\n"
907 . $comments . ' </th>';
911 // 3. Displays the needed checkboxes at the right
912 // column of the result table header if possible and required...
913 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
914 && ($is_display['edit_lnk'] != 'nn' ||
$is_display['del_lnk'] != 'nn')
915 && $is_display['text_btn'] == '1') {
916 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
3 : 1;
917 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
918 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
921 <th
<?php
echo $colspan; ?
>><?php
echo $full_or_partial_text_link;?
>
924 } // end horizontal/horizontalflipped mode
926 $vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
929 } // end vertical mode
932 // ... elseif no button, displays empty columns if required
933 // (unless coming from Browse mode print view)
934 elseif ($GLOBALS['cfg']['ModifyDeleteAtRight']
935 && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
936 && (!$GLOBALS['is_header_sent'])) {
937 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
3 : 1;
938 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
939 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
942 <td
<?php
echo $colspan; ?
>></td
>
944 } // end horizontal/horizontalflipped mode
946 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
947 } // end vertical mode
950 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
951 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
959 } // end of the 'PMA_displayTableHeaders()' function
964 * Displays the body of the results table
966 * @uses $_SESSION['tmp_user_values']['disp_direction']
967 * @uses $_SESSION['tmp_user_values']['repeat_cells']
968 * @uses $_SESSION['tmp_user_values']['max_rows']
969 * @uses $_SESSION['tmp_user_values']['display_text']
970 * @uses $_SESSION['tmp_user_values']['display_binary']
971 * @uses $_SESSION['tmp_user_values']['display_binary_as_hex']
972 * @uses $_SESSION['tmp_user_values']['display_blob']
973 * @param integer the link id associated to the query which results have
975 * @param array which elements to display
976 * @param array the list of relations
977 * @param array the analyzed query
979 * @return boolean always true
981 * @global string $db the database name
982 * @global string $table the table name
983 * @global string $goto the URL to go back in case of errors
984 * @global string $sql_query the SQL query
985 * @global array $fields_meta the list of fields properties
986 * @global integer $fields_cnt the total number of fields returned by
988 * @global array $vertical_display informations used with vertical display
990 * @global array $highlight_columns column names to highlight
991 * @global array $row current row data
995 * @see PMA_displayTable()
997 function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
998 global $db, $table, $goto;
999 global $sql_query, $fields_meta, $fields_cnt;
1000 global $vertical_display, $highlight_columns;
1001 global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin
1003 $url_sql_query = $sql_query;
1005 // query without conditions to shorten URLs when needed, 200 is just
1006 // guess, it should depend on remaining URL length
1008 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
1009 isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
1010 strlen($sql_query) > 200) {
1012 $url_sql_query = 'SELECT ';
1013 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
1014 $url_sql_query .= ' DISTINCT ';
1016 $url_sql_query .= $analyzed_sql[0]['select_expr_clause'];
1017 if (!empty($analyzed_sql[0]['from_clause'])) {
1018 $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
1022 if (!is_array($map)) {
1026 $vertical_display['edit'] = array();
1027 $vertical_display['delete'] = array();
1028 $vertical_display['data'] = array();
1029 $vertical_display['row_delete'] = array();
1031 // Correction University of Virginia 19991216 in the while below
1032 // Previous code assumed that all tables have keys, specifically that
1033 // the phpMyAdmin GUI should support row delete/edit only for such
1035 // Although always using keys is arguably the prescribed way of
1036 // defining a relational table, it is not required. This will in
1037 // particular be violated by the novice.
1038 // We want to encourage phpMyAdmin usage by such novices. So the code
1039 // below has been changed to conditionally work as before when the
1040 // table being displayed has one or more keys; but to display
1041 // delete/edit options correctly for tables without keys.
1044 while ($row = PMA_DBI_fetch_row($dt_result)) {
1045 // lem9: "vertical display" mode stuff
1046 if ($row_no != 0 && $_SESSION['tmp_user_values']['repeat_cells'] != 0 && !($row_no %
$_SESSION['tmp_user_values']['repeat_cells'])
1047 && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1048 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped'))
1051 if ($vertical_display['emptypre'] > 0) {
1052 echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n"
1053 .' </th>' . "\n";
1056 foreach ($vertical_display['desc'] as $val) {
1060 if ($vertical_display['emptyafter'] > 0) {
1061 echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n"
1062 .' </th>' . "\n";
1064 echo '</tr>' . "\n";
1067 $class = $odd_row ?
'odd' : 'even';
1068 $odd_row = ! $odd_row;
1069 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1070 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
1071 // loic1: pointer code part
1072 echo ' <tr class="' . $class . '">' . "\n";
1077 // 1. Prepares the row
1078 // 1.1 Results from a "SELECT" statement -> builds the
1079 // WHERE clause to use in links (a unique key if possible)
1081 * @todo $where_clause could be empty, for example a table
1082 * with only one field and it's a BLOB; in this case,
1083 * avoid to display the delete and edit links
1085 list($where_clause, $clause_is_unique) = PMA_getUniqueCondition($dt_result, $fields_cnt, $fields_meta, $row);
1086 $where_clause_html = urlencode($where_clause);
1088 // 1.2 Defines the URLs for the modify/delete link(s)
1090 if ($is_display['edit_lnk'] != 'nn' ||
$is_display['del_lnk'] != 'nn') {
1091 // We need to copy the value or else the == 'both' check will always return true
1093 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1094 $iconic_spacer = '<div class="nowrap">';
1096 $iconic_spacer = '';
1099 // 1.2.1 Modify link(s)
1100 if ($is_display['edit_lnk'] == 'ur') { // update row case
1101 $_url_params = array(
1104 'where_clause' => $where_clause,
1105 'clause_is_unique' => $clause_is_unique,
1106 'sql_query' => $url_sql_query,
1107 'goto' => 'sql.php',
1109 $edit_url = 'tbl_change.php' . PMA_generate_common_url($_url_params);
1111 $edit_str = PMA_getIcon('b_edit.png', $GLOBALS['strEdit'], true);
1114 if (isset($GLOBALS['cfg']['Bookmark']['table']) && isset($GLOBALS['cfg']['Bookmark']['db']) && $table == $GLOBALS['cfg']['Bookmark']['table'] && $db == $GLOBALS['cfg']['Bookmark']['db'] && isset($row[1]) && isset($row[0])) {
1115 $_url_params = array(
1117 'id_bookmark' => $row[0],
1118 'action_bookmark' => '0',
1119 'action_bookmark_all' => '1',
1120 'SQL' => $GLOBALS['strExecuteBookmarked'],
1122 $bookmark_go = '<a href="import.php'
1123 . PMA_generate_common_url($_url_params)
1124 .' " title="' . $GLOBALS['strExecuteBookmarked'] . '">';
1126 $bookmark_go .= PMA_getIcon('b_bookmark.png', $GLOBALS['strExecuteBookmarked'], true);
1128 $bookmark_go .= '</a>';
1133 // 1.2.2 Delete/Kill link(s)
1134 if ($is_display['del_lnk'] == 'dr') { // delete row case
1135 $_url_params = array(
1138 'sql_query' => $url_sql_query,
1139 'zero_rows' => $GLOBALS['strDeleted'],
1140 'goto' => (empty($goto) ?
'tbl_sql.php' : $goto),
1142 $lnk_goto = 'sql.php' . PMA_generate_common_url($_url_params, 'text');
1144 $del_query = 'DELETE FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)
1145 . ' WHERE ' . $where_clause . ($clause_is_unique ?
'' : ' LIMIT 1');
1147 $_url_params = array(
1150 'sql_query' => $del_query,
1151 'zero_rows' => $GLOBALS['strDeleted'],
1152 'goto' => $lnk_goto,
1154 $del_url = 'sql.php' . PMA_generate_common_url($_url_params);
1156 $js_conf = 'DELETE FROM ' . PMA_jsFormat($db) . '.' . PMA_jsFormat($table)
1157 . ' WHERE ' . PMA_jsFormat($where_clause, false)
1158 . ($clause_is_unique ?
'' : ' LIMIT 1');
1159 $del_str = PMA_getIcon('b_drop.png', $GLOBALS['strDelete'], true);
1160 } elseif ($is_display['del_lnk'] == 'kp') { // kill process case
1162 $_url_params = array(
1165 'sql_query' => $url_sql_query,
1166 'goto' => 'main.php',
1168 $lnk_goto = 'sql.php' . PMA_generate_common_url($_url_params, 'text');
1170 $_url_params = array(
1172 'sql_query' => 'KILL ' . $row[0],
1173 'goto' => $lnk_goto,
1175 $del_url = 'sql.php' . PMA_generate_common_url($_url_params);
1176 $del_query = 'KILL ' . $row[0];
1177 $js_conf = 'KILL ' . $row[0];
1178 $del_str = PMA_getIcon('b_drop.png', $GLOBALS['strKill'], true);
1181 // 1.3 Displays the links at left if required
1182 if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
1183 && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1184 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped')) {
1185 $doWriteModifyAt = 'left';
1186 require './libraries/display_tbl_links.lib.php';
1190 // 2. Displays the rows' values
1191 for ($i = 0; $i < $fields_cnt; ++
$i) {
1192 $meta = $fields_meta[$i];
1194 // garvin: See if this column should get highlight because it's used in the
1196 if (isset($highlight_columns) && (isset($highlight_columns[$meta->name
]) ||
isset($highlight_columns[PMA_backquote($meta->name
)]))) {
1197 $condition_field = true;
1199 $condition_field = false;
1203 if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical' && (!isset($GLOBALS['printview']) ||
($GLOBALS['printview'] != '1'))) {
1204 if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
1205 $mouse_events .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"'
1206 . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');" ';
1208 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
1209 $mouse_events .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
1211 $mouse_events .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
1215 // garvin: Wrap MIME-transformations. [MIME]
1216 $default_function = 'default_function'; // default_function
1217 $transform_function = $default_function;
1218 $transform_options = array();
1220 if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
1222 if (isset($GLOBALS['mime_map'][$meta->name
]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name
]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name
]['transformation'])) {
1223 $include_file = $GLOBALS['mime_map'][$meta->name
]['transformation'];
1225 if (file_exists('./libraries/transformations/' . $include_file)) {
1226 $transformfunction_name = str_replace('.inc.php', '', $GLOBALS['mime_map'][$meta->name
]['transformation']);
1228 require_once './libraries/transformations/' . $include_file;
1230 if (function_exists('PMA_transformation_' . $transformfunction_name)) {
1231 $transform_function = 'PMA_transformation_' . $transformfunction_name;
1232 $transform_options = PMA_transformation_getOptions((isset($GLOBALS['mime_map'][$meta->name
]['transformation_options']) ?
$GLOBALS['mime_map'][$meta->name
]['transformation_options'] : ''));
1233 $meta->mimetype
= str_replace('_', '/', $GLOBALS['mime_map'][$meta->name
]['mimetype']);
1235 } // end if file_exists
1236 } // end if transformation is set
1237 } // end if mime/transformation works.
1239 $_url_params = array(
1242 'where_clause' => $where_clause,
1243 'transform_key' => $meta->name
,
1246 if (! empty($sql_query)) {
1247 $_url_params['sql_query'] = $url_sql_query;
1250 $transform_options['wrapper_link'] = PMA_generate_common_url($_url_params);
1253 if ($meta->numeric == 1) {
1255 // lem9: if two fields have the same name (this is possible
1256 // with self-join queries, for example), using $meta->name
1257 // will show both fields NULL even if only one is NULL,
1258 // so use the $pointer
1260 if (!isset($row[$i]) ||
is_null($row[$i])) {
1261 $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ?
' condition' : '') . '"><i>NULL</i></td>' . "\n";
1262 } elseif ($row[$i] != '') {
1264 $nowrap = ' nowrap';
1265 $where_comparison = ' = ' . $row[$i];
1267 $vertical_display['data'][$row_no][$i] = '<td align="right"' . PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed_sql, $meta, $map, $row[$i], $transform_function, $default_function, $nowrap, $where_comparison, $transform_options);
1269 $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ' nowrap' . ($condition_field ?
' condition' : '') . '"> </td>' . "\n";
1274 } elseif (stristr($meta->type
, 'BLOB')) {
1275 // loic1 : PMA_mysql_fetch_fields returns BLOB in place of
1276 // TEXT fields type so we have to ensure it's really a BLOB
1277 $field_flags = PMA_DBI_field_flags($dt_result, $i);
1278 if (stristr($field_flags, 'BINARY')) {
1279 // rajk - for blobstreaming
1281 $bs_reference_exists = $allBSTablesExist = FALSE;
1283 // load PMA configuration
1284 $PMA_Config = $_SESSION['PMA_Config'];
1286 // if PMA configuration exists
1288 // load BS variables
1289 $pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST');
1291 // if BS plugins exist
1292 if ($pluginsExist) {
1293 // load BS databases
1294 $bs_tables = $PMA_Config->get('BLOBSTREAMABLE_DATABASES');
1296 // if BS db array and specified db string not empty and valid
1297 if (!empty($bs_tables) && strlen($db) > 0) {
1298 $bs_tables = $bs_tables[$db];
1300 if (isset($bs_tables)) {
1301 $allBSTablesExist = TRUE;
1303 // check if BS tables exist for given database
1304 foreach ($bs_tables as $table_key=>$bs_tbl)
1305 if (!$bs_tables[$table_key]['Exists']) {
1306 $allBSTablesExist = FALSE;
1314 // if necessary BS tables exist
1315 if ($allBSTablesExist) {
1316 $bs_reference_exists = PMA_BS_ReferenceExists($row[$i], $db);
1319 // if valid BS reference exists
1320 if ($bs_reference_exists) {
1321 $blobtext = PMA_BS_CreateReferenceLink($row[$i], $db);
1323 $blobtext = PMA_handle_non_printable_contents('BLOB', (isset($row[$i]) ?
$row[$i] : ''), $transform_function, $transform_options, $default_function, $meta);
1326 $vertical_display['data'][$row_no][$i] = ' <td align="left"' . $mouse_events . ' class="' . $class . ($condition_field ?
' condition' : '') . '">' . $blobtext . '</td>';
1330 if (!isset($row[$i]) ||
is_null($row[$i])) {
1331 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ?
' condition' : '') . '"><i>NULL</i></td>' . "\n";
1332 } elseif ($row[$i] != '') {
1333 // garvin: if a transform function for blob is set, none of these replacements will be made
1334 if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['tmp_user_values']['display_text'] == 'P') {
1335 $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1337 // loic1: displays all space characters, 4 space
1338 // characters for tabulations and <cr>/<lf>
1339 $row[$i] = ($default_function != $transform_function ?
$transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1341 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ?
' condition' : '') . '">' . $row[$i] . '</td>' . "\n";
1343 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ?
' condition' : '') . '"> </td>' . "\n";
1346 // n o t n u m e r i c a n d n o t B L O B
1348 if (!isset($row[$i]) ||
is_null($row[$i])) {
1349 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ?
' condition' : '') . '"><i>NULL</i></td>' . "\n";
1350 } elseif ($row[$i] != '') {
1351 // loic1: support blanks in the key
1352 $relation_id = $row[$i];
1354 // nijel: Cut all fields to $GLOBALS['cfg']['LimitChars']
1355 // lem9: (unless it's a link-type transformation)
1356 if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['tmp_user_values']['display_text'] == 'P' && !strpos($transform_function, 'link') === true) {
1357 $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1360 // loic1: displays special characters from binaries
1361 $field_flags = PMA_DBI_field_flags($dt_result, $i);
1362 if (isset($meta->_type
) && $meta->_type
=== MYSQLI_TYPE_BIT
) {
1363 $row[$i] = PMA_printable_bit_value($row[$i], $meta->length
);
1364 // some results of PROCEDURE ANALYSE() are reported as
1365 // being BINARY but they are quite readable,
1366 // so don't treat them as BINARY
1367 } elseif (stristr($field_flags, 'BINARY') && $meta->type
== 'string' && !(isset($GLOBALS['is_analyse']) && $GLOBALS['is_analyse'])) {
1368 if ($_SESSION['tmp_user_values']['display_binary']) {
1369 // user asked to see the real contents of BINARY
1371 if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && PMA_contains_nonprintable_ascii($row[$i])) {
1372 $row[$i] = bin2hex($row[$i]);
1375 $row[$i] = htmlspecialchars(PMA_replace_binary_contents($row[$i]));
1378 // we show the BINARY message and field's size
1379 // (or maybe use a transformation)
1380 $row[$i] = PMA_handle_non_printable_contents('BINARY', $row[$i], $transform_function, $transform_options, $default_function, $meta);
1384 // garvin: transform functions may enable no-wrapping:
1385 $function_nowrap = $transform_function . '_nowrap';
1386 $bool_nowrap = (($default_function != $transform_function && function_exists($function_nowrap)) ?
$function_nowrap($transform_options) : false);
1388 // loic1: do not wrap if date field type
1389 $nowrap = ((preg_match('@DATE|TIME@i', $meta->type
) ||
$bool_nowrap) ?
' nowrap' : '');
1390 $where_comparison = ' = \'' . PMA_sqlAddslashes($row[$i]) . '\'';
1391 $vertical_display['data'][$row_no][$i] = '<td ' . PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed_sql, $meta, $map, $row[$i], $transform_function, $default_function, $nowrap, $where_comparison, $transform_options);
1394 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ?
' condition' : '') . '"> </td>' . "\n";
1398 // lem9: output stored cell
1399 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1400 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
1401 echo $vertical_display['data'][$row_no][$i];
1404 if (isset($vertical_display['rowdata'][$i][$row_no])) {
1405 $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i];
1407 $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i];
1411 // 3. Displays the modify/delete links on the right if required
1412 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
1413 && ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1414 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped')) {
1415 $doWriteModifyAt = 'right';
1416 require './libraries/display_tbl_links.lib.php';
1419 if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal'
1420 ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
1426 // 4. Gather links of del_urls and edit_urls in an array for later
1428 if (!isset($vertical_display['edit'][$row_no])) {
1429 $vertical_display['edit'][$row_no] = '';
1430 $vertical_display['delete'][$row_no] = '';
1431 $vertical_display['row_delete'][$row_no] = '';
1434 $column_style_vertical = '';
1435 if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
1436 $column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"'
1437 . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');"';
1439 $column_marker_vertical = '';
1440 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
1441 $column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\');';
1444 if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
1445 $vertical_display['row_delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
1446 . ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $where_clause_html . ']"'
1447 . ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"'
1448 . ' value="' . htmlspecialchars($del_query) . '" ' . (isset($GLOBALS['checkall']) ?
'checked="checked"' : '') . ' />' . "\n"
1451 unset($vertical_display['row_delete'][$row_no]);
1454 if (isset($edit_url)) {
1455 $vertical_display['edit'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
1456 . PMA_linkOrButton($edit_url, $edit_str, array(), false)
1460 unset($vertical_display['edit'][$row_no]);
1463 if (isset($del_url)) {
1464 $vertical_display['delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
1465 . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ?
$js_conf : ''), false)
1468 unset($vertical_display['delete'][$row_no]);
1471 echo (($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' ||
$_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') ?
"\n" : '');
1475 // this is needed by PMA_displayTable() to generate the proper param
1476 // in the multi-edit and multi-delete form
1477 return $clause_is_unique;
1478 } // end of the 'PMA_displayTableBody()' function
1482 * Do display the result table with the vertical direction mode.
1483 * Credits for this feature goes to Garvin Hicking <hicking@faktor-e.de>.
1485 * @return boolean always true
1487 * @uses $_SESSION['tmp_user_values']['repeat_cells']
1488 * @global array $vertical_display the information to display
1492 * @see PMA_displayTable()
1494 function PMA_displayVerticalTable()
1496 global $vertical_display;
1498 // Displays "multi row delete" link at top if required
1499 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 ||
!empty($vertical_display['textbtn']))) {
1501 echo $vertical_display['textbtn'];
1503 foreach ($vertical_display['row_delete'] as $val) {
1504 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter %
$_SESSION['tmp_user_values']['repeat_cells'])) {
1505 echo '<th></th>' . "\n";
1508 echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '', $val);
1511 echo '</tr>' . "\n";
1514 // Displays "edit" link at top if required
1515 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 ||
!empty($vertical_display['textbtn']))) {
1517 if (!is_array($vertical_display['row_delete'])) {
1518 echo $vertical_display['textbtn'];
1521 foreach ($vertical_display['edit'] as $val) {
1522 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter %
$_SESSION['tmp_user_values']['repeat_cells'])) {
1523 echo ' <th></th>' . "\n";
1529 echo '</tr>' . "\n";
1532 // Displays "delete" link at top if required
1533 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 ||
!empty($vertical_display['textbtn']))) {
1535 if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
1536 echo $vertical_display['textbtn'];
1539 foreach ($vertical_display['delete'] as $val) {
1540 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter %
$_SESSION['tmp_user_values']['repeat_cells'])) {
1541 echo '<th></th>' . "\n";
1547 echo '</tr>' . "\n";
1551 foreach ($vertical_display['desc'] AS $key => $val) {
1557 foreach ($vertical_display['rowdata'][$key] as $subval) {
1558 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) and !($foo_counter %
$_SESSION['tmp_user_values']['repeat_cells'])) {
1566 echo '</tr>' . "\n";
1569 // Displays "multi row delete" link at bottom if required
1570 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 ||
!empty($vertical_display['textbtn']))) {
1572 echo $vertical_display['textbtn'];
1574 foreach ($vertical_display['row_delete'] as $val) {
1575 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter %
$_SESSION['tmp_user_values']['repeat_cells'])) {
1576 echo '<th></th>' . "\n";
1579 echo str_replace('[%_PMA_CHECKBOX_DIR_%]', 'r', $val);
1582 echo '</tr>' . "\n";
1585 // Displays "edit" link at bottom if required
1586 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 ||
!empty($vertical_display['textbtn']))) {
1588 if (!is_array($vertical_display['row_delete'])) {
1589 echo $vertical_display['textbtn'];
1592 foreach ($vertical_display['edit'] as $val) {
1593 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter %
$_SESSION['tmp_user_values']['repeat_cells'])) {
1594 echo '<th></th>' . "\n";
1600 echo '</tr>' . "\n";
1603 // Displays "delete" link at bottom if required
1604 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 ||
!empty($vertical_display['textbtn']))) {
1606 if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
1607 echo $vertical_display['textbtn'];
1610 foreach ($vertical_display['delete'] as $val) {
1611 if (($foo_counter != 0) && ($_SESSION['tmp_user_values']['repeat_cells'] != 0) && !($foo_counter %
$_SESSION['tmp_user_values']['repeat_cells'])) {
1612 echo '<th></th>' . "\n";
1618 echo '</tr>' . "\n";
1622 } // end of the 'PMA_displayVerticalTable' function
1626 * @uses $_SESSION['tmp_user_values']['disp_direction']
1627 * @uses $_REQUEST['disp_direction']
1628 * @uses $GLOBALS['cfg']['DefaultDisplay']
1629 * @uses $_SESSION['tmp_user_values']['repeat_cells']
1630 * @uses $_REQUEST['repeat_cells']
1631 * @uses $GLOBALS['cfg']['RepeatCells']
1632 * @uses $_SESSION['tmp_user_values']['max_rows']
1633 * @uses $_REQUEST['session_max_rows']
1634 * @uses $GLOBALS['cfg']['MaxRows']
1635 * @uses $_SESSION['tmp_user_values']['pos']
1636 * @uses $_REQUEST['pos']
1637 * @uses $_SESSION['tmp_user_values']['display_text']
1638 * @uses $_REQUEST['display_text']
1639 * @uses $_SESSION['tmp_user_values']['relational_display']
1640 * @uses $_REQUEST['relational_display']
1641 * @uses $_SESSION['tmp_user_values']['display_binary']
1642 * @uses $_REQUEST['display_binary']
1643 * @uses $_SESSION['tmp_user_values']['display_binary_as_hex']
1644 * @uses $_REQUEST['display_binary_as_hex']
1645 * @uses $_SESSION['tmp_user_values']['display_blob']
1646 * @uses $_REQUEST['display_blob']
1647 * @uses PMA_isValid()
1648 * @uses $GLOBALS['sql_query']
1649 * @todo make maximum remembered queries configurable
1650 * @todo move/split into SQL class!?
1651 * @todo currently this is called twice unnecessary
1652 * @todo ignore LIMIT and ORDER in query!?
1654 function PMA_displayTable_checkConfigParams()
1656 $sql_key = md5($GLOBALS['sql_query']);
1658 $_SESSION['tmp_user_values']['query'][$sql_key]['sql'] = $GLOBALS['sql_query'];
1660 if (PMA_isValid($_REQUEST['disp_direction'], array('horizontal', 'vertical', 'horizontalflipped'))) {
1661 $_SESSION['tmp_user_values']['query'][$sql_key]['disp_direction'] = $_REQUEST['disp_direction'];
1662 unset($_REQUEST['disp_direction']);
1663 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['disp_direction'])) {
1664 $_SESSION['tmp_user_values']['query'][$sql_key]['disp_direction'] = $GLOBALS['cfg']['DefaultDisplay'];
1667 if (PMA_isValid($_REQUEST['repeat_cells'], 'numeric')) {
1668 $_SESSION['tmp_user_values']['query'][$sql_key]['repeat_cells'] = $_REQUEST['repeat_cells'];
1669 unset($_REQUEST['repeat_cells']);
1670 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['repeat_cells'])) {
1671 $_SESSION['tmp_user_values']['query'][$sql_key]['repeat_cells'] = $GLOBALS['cfg']['RepeatCells'];
1674 // as this is a form value, the type is always string so we cannot
1675 // use PMA_isValid($_REQUEST['session_max_rows'], 'integer')
1676 if ((PMA_isValid($_REQUEST['session_max_rows'], 'numeric')
1677 && (int) $_REQUEST['session_max_rows'] == $_REQUEST['session_max_rows'])
1678 ||
$_REQUEST['session_max_rows'] == 'all') {
1679 $_SESSION['tmp_user_values']['query'][$sql_key]['max_rows'] = $_REQUEST['session_max_rows'];
1680 unset($_REQUEST['session_max_rows']);
1681 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['max_rows'])) {
1682 $_SESSION['tmp_user_values']['query'][$sql_key]['max_rows'] = $GLOBALS['cfg']['MaxRows'];
1685 if (PMA_isValid($_REQUEST['pos'], 'numeric')) {
1686 $_SESSION['tmp_user_values']['query'][$sql_key]['pos'] = $_REQUEST['pos'];
1687 unset($_REQUEST['pos']);
1688 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['pos'])) {
1689 $_SESSION['tmp_user_values']['query'][$sql_key]['pos'] = 0;
1692 if (PMA_isValid($_REQUEST['display_text'], array('P', 'F'))) {
1693 $_SESSION['tmp_user_values']['query'][$sql_key]['display_text'] = $_REQUEST['display_text'];
1694 unset($_REQUEST['display_text']);
1695 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['display_text'])) {
1696 $_SESSION['tmp_user_values']['query'][$sql_key]['display_text'] = 'P';
1699 if (PMA_isValid($_REQUEST['relational_display'], array('K', 'D'))) {
1700 $_SESSION['tmp_user_values']['query'][$sql_key]['relational_display'] = $_REQUEST['relational_display'];
1701 unset($_REQUEST['relational_display']);
1702 } elseif (empty($_SESSION['tmp_user_values']['query'][$sql_key]['relational_display'])) {
1703 $_SESSION['tmp_user_values']['query'][$sql_key]['relational_display'] = 'K';
1706 if (isset($_REQUEST['display_binary'])) {
1707 $_SESSION['tmp_user_values']['query'][$sql_key]['display_binary'] = true;
1708 unset($_REQUEST['display_binary']);
1709 } elseif (isset($_REQUEST['display_options_form'])) {
1710 // we know that the checkbox was unchecked
1711 unset($_SESSION['tmp_user_values']['query'][$sql_key]['display_binary']);
1713 // selected by default because some operations like OPTIMIZE TABLE
1714 // and all queries involving functions return "binary" contents,
1715 // according to low-level field flags
1716 $_SESSION['tmp_user_values']['query'][$sql_key]['display_binary'] = true;
1719 if (isset($_REQUEST['display_binary_as_hex'])) {
1720 $_SESSION['tmp_user_values']['query'][$sql_key]['display_binary_as_hex'] = true;
1721 unset($_REQUEST['display_binary_as_hex']);
1722 } elseif (isset($_REQUEST['display_options_form'])) {
1723 // we know that the checkbox was unchecked
1724 unset($_SESSION['tmp_user_values']['query'][$sql_key]['display_binary_as_hex']);
1726 // display_binary_as_hex config option
1727 if (isset($GLOBALS['cfg']['DisplayBinaryAsHex']) && true === $GLOBALS['cfg']['DisplayBinaryAsHex']) {
1728 $_SESSION['tmp_user_values']['query'][$sql_key]['display_binary_as_hex'] = true;
1732 if (isset($_REQUEST['display_blob'])) {
1733 $_SESSION['tmp_user_values']['query'][$sql_key]['display_blob'] = true;
1734 unset($_REQUEST['display_blob']);
1735 } elseif (isset($_REQUEST['display_options_form'])) {
1736 // we know that the checkbox was unchecked
1737 unset($_SESSION['tmp_user_values']['query'][$sql_key]['display_blob']);
1740 if (isset($_REQUEST['hide_transformation'])) {
1741 $_SESSION['tmp_user_values']['query'][$sql_key]['hide_transformation'] = true;
1742 unset($_REQUEST['hide_transformation']);
1743 } elseif (isset($_REQUEST['display_options_form'])) {
1744 // we know that the checkbox was unchecked
1745 unset($_SESSION['tmp_user_values']['query'][$sql_key]['hide_transformation']);
1748 // move current query to the last position, to be removed last
1749 // so only least executed query will be removed if maximum remembered queries
1751 $tmp = $_SESSION['tmp_user_values']['query'][$sql_key];
1752 unset($_SESSION['tmp_user_values']['query'][$sql_key]);
1753 $_SESSION['tmp_user_values']['query'][$sql_key] = $tmp;
1755 // do not exceed a maximum number of queries to remember
1756 if (count($_SESSION['tmp_user_values']['query']) > 10) {
1757 array_shift($_SESSION['tmp_user_values']['query']);
1758 //echo 'deleting one element ...';
1761 // populate query configuration
1762 $_SESSION['tmp_user_values']['display_text'] = $_SESSION['tmp_user_values']['query'][$sql_key]['display_text'];
1763 $_SESSION['tmp_user_values']['relational_display'] = $_SESSION['tmp_user_values']['query'][$sql_key]['relational_display'];
1764 $_SESSION['tmp_user_values']['display_binary'] = isset($_SESSION['tmp_user_values']['query'][$sql_key]['display_binary']) ?
true : false;
1765 $_SESSION['tmp_user_values']['display_binary_as_hex'] = isset($_SESSION['tmp_user_values']['query'][$sql_key]['display_binary_as_hex']) ?
true : false;
1766 $_SESSION['tmp_user_values']['display_blob'] = isset($_SESSION['tmp_user_values']['query'][$sql_key]['display_blob']) ?
true : false;
1767 $_SESSION['tmp_user_values']['hide_transformation'] = isset($_SESSION['tmp_user_values']['query'][$sql_key]['hide_transformation']) ?
true : false;
1768 $_SESSION['tmp_user_values']['pos'] = $_SESSION['tmp_user_values']['query'][$sql_key]['pos'];
1769 $_SESSION['tmp_user_values']['max_rows'] = $_SESSION['tmp_user_values']['query'][$sql_key]['max_rows'];
1770 $_SESSION['tmp_user_values']['repeat_cells'] = $_SESSION['tmp_user_values']['query'][$sql_key]['repeat_cells'];
1771 $_SESSION['tmp_user_values']['disp_direction'] = $_SESSION['tmp_user_values']['query'][$sql_key]['disp_direction'];
1776 var_dump($_SESSION['tmp_user_values']);
1782 * Displays a table of results returned by a SQL query.
1783 * This function is called by the "sql.php" script.
1785 * @param integer the link id associated to the query which results have
1787 * @param array the display mode
1788 * @param array the analyzed query
1790 * @uses $_SESSION['tmp_user_values']['pos']
1791 * @global string $db the database name
1792 * @global string $table the table name
1793 * @global string $goto the URL to go back in case of errors
1794 * @global string $sql_query the current SQL query
1795 * @global integer $num_rows the total number of rows returned by the
1797 * @global integer $unlim_num_rows the total number of rows returned by the
1798 * SQL query without any programmatically
1799 * appended "LIMIT" clause
1800 * @global array $fields_meta the list of fields properties
1801 * @global integer $fields_cnt the total number of fields returned by
1803 * @global array $vertical_display informations used with vertical display
1805 * @global array $highlight_columns column names to highlight
1806 * @global array $cfgRelation the relation settings
1810 * @see PMA_showMessage(), PMA_setDisplayMode(),
1811 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
1812 * PMA_displayTableBody(), PMA_displayResultsOperations()
1814 function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
1816 global $db, $table, $goto;
1817 global $sql_query, $num_rows, $unlim_num_rows, $fields_meta, $fields_cnt;
1818 global $vertical_display, $highlight_columns;
1819 global $cfgRelation;
1822 // why was this called here? (already called from sql.php)
1823 //PMA_displayTable_checkConfigParams();
1826 * @todo move this to a central place
1827 * @todo for other future table types
1829 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
1832 && ! isset($analyzed_sql[0]['queryflags']['union'])
1833 && ! isset($analyzed_sql[0]['table_ref'][1]['table_name'])
1834 && (empty($analyzed_sql[0]['where_clause'])
1835 ||
$analyzed_sql[0]['where_clause'] == '1 ')) {
1836 // "j u s t b r o w s i n g"
1838 $after_count = PMA_showHint(PMA_sanitize($GLOBALS['strApproximateCount']), true);
1844 // 1. ----- Prepares the work -----
1846 // 1.1 Gets the informations about which functionalities should be
1849 $is_display = PMA_setDisplayMode($the_disp_mode, $total);
1851 // 1.2 Defines offsets for the next and previous pages
1852 if ($is_display['nav_bar'] == '1') {
1853 if ($_SESSION['tmp_user_values']['max_rows'] == 'all') {
1857 $pos_next = $_SESSION['tmp_user_values']['pos'] +
$_SESSION['tmp_user_values']['max_rows'];
1858 $pos_prev = $_SESSION['tmp_user_values']['pos'] - $_SESSION['tmp_user_values']['max_rows'];
1859 if ($pos_prev < 0) {
1865 // 1.3 Find the sort expression
1867 // we need $sort_expression and $sort_expression_nodirection
1868 // even if there are many table references
1869 if (! empty($analyzed_sql[0]['order_by_clause'])) {
1870 $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
1872 * Get rid of ASC|DESC
1874 preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
1875 $sort_expression_nodirection = isset($matches[1]) ?
trim($matches[1]) : $sort_expression;
1876 $sort_direction = isset($matches[2]) ?
trim($matches[2]) : '';
1879 $sort_expression = $sort_expression_nodirection = $sort_direction = '';
1882 // 1.4 Prepares display of first and last value of the sorted column
1884 if (! empty($sort_expression_nodirection)) {
1885 if (strpos($sort_expression_nodirection, '.') === false) {
1886 $sort_table = $table;
1887 $sort_column = $sort_expression_nodirection;
1889 list($sort_table, $sort_column) = explode('.', $sort_expression_nodirection);
1891 $sort_table = PMA_unQuote($sort_table);
1892 $sort_column = PMA_unQuote($sort_column);
1893 // find the sorted column index in row result
1894 // (this might be a multi-table query)
1895 $sorted_column_index = false;
1896 foreach($fields_meta as $key => $meta) {
1897 if ($meta->table
== $sort_table && $meta->name
== $sort_column) {
1898 $sorted_column_index = $key;
1902 if ($sorted_column_index !== false) {
1903 // fetch first row of the result set
1904 $row = PMA_DBI_fetch_row($dt_result);
1905 $column_for_first_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
1906 // fetch last row of the result set
1907 PMA_DBI_data_seek($dt_result, $num_rows - 1);
1908 $row = PMA_DBI_fetch_row($dt_result);
1909 $column_for_last_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
1910 // reset to first row for the loop in PMA_displayTableBody()
1911 PMA_DBI_data_seek($dt_result, 0);
1912 // we could also use here $sort_expression_nodirection
1913 $sorted_column_message = ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]';
1914 unset($row, $column_for_first_row, $column_for_last_row);
1916 unset($sorted_column_index, $sort_table, $sort_column);
1919 // 2. ----- Displays the top of the page -----
1921 // 2.1 Displays a messages with position informations
1922 if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
1923 if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
1924 $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
1928 $last_shown_rec = ($_SESSION['tmp_user_values']['max_rows'] == 'all' ||
$pos_next > $total)
1932 if (PMA_Table
::isView($db, $table)
1933 && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
1934 $message = PMA_Message
::notice('strViewHasAtLeast');
1935 $message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]');
1936 $message->addParam('[/a]');
1937 $message_view_warning = PMA_showHint($message);
1939 $message_view_warning = false;
1942 $message = PMA_Message
::success('strShowingRecords');
1943 $message->addMessage($_SESSION['tmp_user_values']['pos']);
1944 if ($message_view_warning) {
1945 $message->addMessage('...', ' - ');
1946 $message->addMessage($message_view_warning);
1947 $message->addMessage('(');
1949 $message->addMessage($last_shown_rec, ' - ');
1950 $message->addMessage($pre_count . PMA_formatNumber($total, 0) . $after_count, ' (');
1951 $message->addString('strTotal');
1952 $message->addMessage($selectstring, '');
1953 $message->addMessage(', ', '');
1956 $messagge_qt = PMA_Message
::notice('strQueryTime');
1957 $messagge_qt->addParam($GLOBALS['querytime']);
1959 $message->addMessage($messagge_qt, '');
1960 $message->addMessage(')', '');
1962 $message->addMessage(isset($sorted_column_message) ?
$sorted_column_message : '', '');
1964 PMA_showMessage($message, $sql_query, 'success');
1966 } elseif (!isset($GLOBALS['printview']) ||
$GLOBALS['printview'] != '1') {
1967 PMA_showMessage($GLOBALS['strSuccess'], $sql_query, 'success');
1970 // 2.3 Displays the navigation bars
1971 if (! strlen($table)) {
1972 if (isset($analyzed_sql[0]['query_type'])
1973 && $analyzed_sql[0]['query_type'] == 'SELECT') {
1974 // table does not always contain a real table name,
1975 // for example in MySQL 5.0.x, the query SHOW STATUS
1976 // returns STATUS as a table name
1977 $table = $fields_meta[0]->table
;
1983 if ($is_display['nav_bar'] == '1') {
1984 PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'top_direction_dropdown');
1986 } elseif (!isset($GLOBALS['printview']) ||
$GLOBALS['printview'] != '1') {
1987 echo "\n" . '<br /><br />' . "\n";
1990 // 2b ----- Get field references from Database -----
1991 // (see the 'relation' configuration variable)
1992 // loic1, 2002-03-02: extended to php3
1999 if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
2000 foreach ($analyzed_sql[0]['table_ref'] AS $table_ref_position => $table_ref) {
2001 $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
2004 $tabs = '(\'' . join('\',\'', $target) . '\')';
2006 if ($cfgRelation['displaywork']) {
2007 if (! strlen($table)) {
2010 $exist_rel = PMA_getForeigners($db, $table, '', 'both');
2012 foreach ($exist_rel AS $master_field => $rel) {
2013 $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
2014 $map[$master_field] = array($rel['foreign_table'],
2015 $rel['foreign_field'],
2017 $rel['foreign_db']);
2024 // 3. ----- Displays the results table -----
2025 PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql, $sort_expression, $sort_expression_nodirection, $sort_direction);
2027 echo '<tbody>' . "\n";
2028 $clause_is_unique = PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
2029 // vertical output case
2030 if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') {
2031 PMA_displayVerticalTable();
2033 unset($vertical_display);
2034 echo '</tbody>' . "\n";
2039 // 4. ----- Displays the link for multi-fields edit and delete
2041 if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
2043 $delete_text = $is_display['del_lnk'] == 'dr' ?
$GLOBALS['strDelete'] : $GLOBALS['strKill'];
2045 $_url_params = array(
2048 'sql_query' => $sql_query,
2051 $uncheckall_url = 'sql.php' . PMA_generate_common_url($_url_params);
2053 $_url_params['checkall'] = '1';
2054 $checkall_url = 'sql.php' . PMA_generate_common_url($_url_params);
2056 if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') {
2057 $checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;';
2058 $uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;';
2060 $checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;';
2061 $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;';
2063 $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
2064 $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
2065 if ($_SESSION['tmp_user_values']['disp_direction'] != 'vertical') {
2066 echo '<img class="selectallarrow" width="38" height="22"'
2067 .' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"'
2068 .' alt="' . $GLOBALS['strWithChecked'] . '" />';
2070 echo $checkall_link . "\n"
2072 .$uncheckall_link . "\n"
2073 .'<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
2075 PMA_buttonOrImage('submit_mult', 'mult_submit',
2076 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
2077 PMA_buttonOrImage('submit_mult', 'mult_submit',
2078 'submit_mult_delete', $delete_text, 'b_drop.png');
2079 if ($analyzed_sql[0]['querytype'] == 'SELECT') {
2080 PMA_buttonOrImage('submit_mult', 'mult_submit',
2081 'submit_mult_export', $GLOBALS['strExport'],
2086 echo '<input type="hidden" name="sql_query"'
2087 .' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
2088 echo '<input type="hidden" name="url_query"'
2089 .' value="' . $GLOBALS['url_query'] . '" />' . "\n";
2091 echo '<input type="hidden" name="clause_is_unique"'
2092 .' value="' . $clause_is_unique . '" />' . "\n";
2094 echo '</form>' . "\n";
2097 // 5. ----- Displays the navigation bar at the bottom if required -----
2099 if ($is_display['nav_bar'] == '1') {
2100 echo '<br />' . "\n";
2101 PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'bottom_direction_dropdown');
2102 } elseif (!isset($GLOBALS['printview']) ||
$GLOBALS['printview'] != '1') {
2103 echo "\n" . '<br /><br />' . "\n";
2106 // 6. ----- Displays "Query results operations"
2107 if (!isset($GLOBALS['printview']) ||
$GLOBALS['printview'] != '1') {
2108 PMA_displayResultsOperations($the_disp_mode, $analyzed_sql);
2110 } // end of the 'PMA_displayTable()' function
2112 function default_function($buffer) {
2113 $buffer = htmlspecialchars($buffer);
2114 $buffer = str_replace("\011", ' ',
2115 str_replace(' ', ' ', $buffer));
2116 $buffer = preg_replace("@((\015\012)|(\015)|(\012))@", '<br />', $buffer);
2122 * Displays operations that are available on results.
2124 * @param array the display mode
2125 * @param array the analyzed query
2127 * @uses $_SESSION['tmp_user_values']['pos']
2128 * @uses $_SESSION['tmp_user_values']['display_text']
2129 * @global string $db the database name
2130 * @global string $table the table name
2131 * @global string $sql_query the current SQL query
2132 * @global integer $unlim_num_rows the total number of rows returned by the
2133 * SQL query without any programmatically
2134 * appended "LIMIT" clause
2138 * @see PMA_showMessage(), PMA_setDisplayMode(),
2139 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
2140 * PMA_displayTableBody(), PMA_displayResultsOperations()
2142 function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
2143 global $db, $table, $sql_query, $unlim_num_rows;
2145 $header_shown = FALSE;
2146 $header = '<fieldset><legend>' . $GLOBALS['strQueryResultsOperations'] . '</legend>';
2148 if ($the_disp_mode[6] == '1' ||
$the_disp_mode[9] == '1') {
2149 // Displays "printable view" link if required
2150 if ($the_disp_mode[9] == '1') {
2152 if (!$header_shown) {
2154 $header_shown = TRUE;
2157 $_url_params = array(
2161 'sql_query' => $sql_query,
2163 $url_query = PMA_generate_common_url($_url_params);
2165 echo PMA_linkOrButton(
2166 'sql.php' . $url_query,
2167 PMA_getIcon('b_print.png', $GLOBALS['strPrintView'], false, true),
2168 '', true, true, 'print_view') . "\n";
2170 if ($_SESSION['tmp_user_values']['display_text']) {
2171 $_url_params['display_text'] = 'F';
2172 echo PMA_linkOrButton(
2173 'sql.php' . PMA_generate_common_url($_url_params),
2174 PMA_getIcon('b_print.png', $GLOBALS['strPrintViewFull'], false, true),
2175 '', true, true, 'print_view') . "\n";
2176 unset($_url_params['display_text']);
2178 } // end displays "printable view"
2182 // (the url_query has extra parameters that won't be used to export)
2183 // (the single_table parameter is used in display_export.lib.php
2184 // to hide the SQL and the structure export dialogs)
2185 // If the parser found a PROCEDURE clause
2186 // (most probably PROCEDURE ANALYSE()) it makes no sense to
2187 // display the Export link).
2188 if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT' && !isset($printview) && ! isset($analyzed_sql[0]['queryflags']['procedure'])) {
2189 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
2190 $_url_params['single_table'] = 'true';
2192 if (!$header_shown) {
2194 $header_shown = TRUE;
2196 $_url_params['unlim_num_rows'] = $unlim_num_rows;
2199 * At this point we don't know the table name; this can happen
2200 * for example with a query like
2201 * SELECT bike_code FROM (SELECT bike_code FROM bikes) tmp
2202 * As a workaround we set in the table parameter the name of the
2203 * first table of this database, so that tbl_export.php and
2204 * the script it calls do not fail
2206 if (empty($_url_params['table'])) {
2207 $_url_params['table'] = PMA_DBI_fetch_value("SHOW TABLES");
2210 echo PMA_linkOrButton(
2211 'tbl_export.php' . PMA_generate_common_url($_url_params),
2212 PMA_getIcon('b_tblexport.png', $GLOBALS['strExport'], false, true),
2213 '', true, true, '') . "\n";
2219 * @todo detect privileges to create a view
2220 * (but see 2006-01-19 note in display_create_table.lib.php,
2221 * I think we cannot detect db-specific privileges reliably)
2222 * Note: we don't display a Create view link if we found a PROCEDURE clause
2224 if (!$header_shown) {
2226 $header_shown = TRUE;
2228 if (! isset($analyzed_sql[0]['queryflags']['procedure'])) {
2229 echo PMA_linkOrButton(
2230 'view_create.php' . $url_query,
2231 PMA_getIcon('b_views.png', 'CREATE VIEW', false, true),
2232 '', true, true, '') . "\n";
2234 if ($header_shown) {
2235 echo '</fieldset><br />';
2240 * Verifies what to do with non-printable contents (binary or BLOB)
2246 * @uses PMA_formatByteDown()
2248 * @uses str_replace()
2249 * @param string $category BLOB|BINARY
2250 * @param string $content the binary content
2251 * @param string $transform_function
2252 * @param string $transform_options
2253 * @param string $default_function
2254 * @param object $meta the meta-information about this field
2255 * @return mixed string or float
2257 function PMA_handle_non_printable_contents($category, $content, $transform_function, $transform_options, $default_function, $meta) {
2258 $result = '[' . $category;
2259 if (is_null($content)) {
2260 $result .= ' - NULL';
2262 } elseif (isset($content)) {
2263 $size = strlen($content);
2264 $display_size = PMA_formatByteDown($size, 3, 1);
2265 $result .= ' - '. $display_size[0] . $display_size[1];
2269 if (strpos($transform_function, 'octetstream')) {
2273 if ($default_function != $transform_function) {
2274 $result = $transform_function($result, $transform_options, $meta);
2276 $result = $default_function($result, array(), $meta);
2277 if (stristr($meta->type
, 'BLOB') && $_SESSION['tmp_user_values']['display_blob']) {
2278 // in this case, restart from the original $content
2279 $result = htmlspecialchars(PMA_replace_binary_contents($content));
2287 * Prepares the displayable content of a data cell in Browse mode,
2288 * taking into account foreign key description field and transformations
2291 * @uses PMA_backquote()
2292 * @uses PMA_DBI_try_query()
2293 * @uses PMA_DBI_num_rows()
2294 * @uses PMA_DBI_fetch_row()
2295 * @uses $GLOBALS['strLinkNotFound']
2296 * @uses PMA_DBI_free_result()
2297 * @uses $GLOBALS['printview']
2298 * @uses htmlspecialchars()
2299 * @uses PMA_generate_common_url()
2300 * @param string $mouse_events
2301 * @param string $class
2302 * @param string $condition_field
2303 * @param string $analyzed_sql
2304 * @param object $meta the meta-information about this field
2305 * @param string $map
2306 * @param string $data
2307 * @param string $transform_function
2308 * @param string $default_function
2309 * @param string $nowrap
2310 * @param string $where_comparison
2311 * @return string formatted data
2313 function PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed_sql, $meta, $map, $data, $transform_function, $default_function, $nowrap, $where_comparison, $transform_options) {
2315 // continue the <td> tag started before calling this function:
2316 $result = $mouse_events . ' class="' . $class . ($condition_field ?
' condition' : '') . $nowrap . '">';
2318 if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
2319 foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
2320 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
2321 if (isset($alias) && strlen($alias)) {
2322 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
2323 if ($alias == $meta->name
) {
2324 // this change in the parameter does not matter
2325 // outside of the function
2326 $meta->name
= $true_column;
2332 if (isset($map[$meta->name
])) {
2333 // Field to display from the foreign table?
2334 if (isset($map[$meta->name
][2]) && strlen($map[$meta->name
][2])) {
2335 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name
][2])
2336 . ' FROM ' . PMA_backquote($map[$meta->name
][3])
2337 . '.' . PMA_backquote($map[$meta->name
][0])
2338 . ' WHERE ' . PMA_backquote($map[$meta->name
][1])
2339 . $where_comparison;
2340 $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE
);
2341 if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
2342 list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
2344 $dispval = $GLOBALS['strLinkNotFound'];
2346 @PMA_DBI_free_result
($dispresult);
2349 } // end if... else...
2351 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
2352 $result .= ($transform_function != $default_function ?
$transform_function($data, $transform_options, $meta) : $transform_function($data, array(), $meta)) . ' <code>[->' . $dispval . ']</code>';
2355 if ('K' == $_SESSION['tmp_user_values']['relational_display']) {
2356 // user chose "relational key" in the display options, so
2357 // the title contains the display field
2358 $title = (! empty($dispval))?
' title="' . htmlspecialchars($dispval) . '"' : '';
2360 $title = ' title="' . htmlspecialchars($data) . '"';
2363 $_url_params = array(
2364 'db' => $map[$meta->name
][3],
2365 'table' => $map[$meta->name
][0],
2367 'sql_query' => 'SELECT * FROM '
2368 . PMA_backquote($map[$meta->name
][3]) . '.' . PMA_backquote($map[$meta->name
][0])
2369 . ' WHERE ' . PMA_backquote($map[$meta->name
][1])
2370 . $where_comparison,
2372 $result .= '<a href="sql.php' . PMA_generate_common_url($_url_params)
2373 . '"' . $title . '>';
2375 if ($transform_function != $default_function) {
2376 // always apply a transformation on the real data,
2377 // not on the display field
2378 $result .= $transform_function($data, $transform_options, $meta);
2380 if ('D' == $_SESSION['tmp_user_values']['relational_display']) {
2381 // user chose "relational display field" in the
2382 // display options, so show display field in the cell
2383 $result .= $transform_function($dispval, array(), $meta);
2385 // otherwise display data in the cell
2386 $result .= $transform_function($data, array(), $meta);
2392 $result .= ($transform_function != $default_function ?
$transform_function($data, $transform_options, $meta) : $transform_function($data, array(), $meta));
2394 $result .= '</td>' . "\n";