XHTML fixes
[phpmyadmin/crack.git] / libraries / display_tbl.lib.php
blob0921a2823f4cf4be94bfac0759678eb127443005
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
8 /**
11 require_once './libraries/Table.class.php';
13 /**
14 * Set of functions used to display the records returned by a SQL query
17 /**
18 * Defines the display mode to use for the results of a SQL query
20 * It uses a synthetic string that contains all the required informations.
21 * In this string:
22 * - the first two characters stand for the action to do while
23 * clicking on the "edit" link (e.g. 'ur' for update a row, 'nn' for no
24 * edit link...);
25 * - the next two characters stand for the action to do while
26 * clicking on the "delete" link (e.g. 'kp' for kill a process, 'nn' for
27 * no delete link...);
28 * - the next characters are boolean values (1/0) and respectively stand
29 * for sorting links, navigation bar, "insert a new row" link, the
30 * bookmark feature, the expand/collapse text/blob fields button and
31 * the "display printable view" option.
32 * Of course '0'/'1' means the feature won't/will be enabled.
34 * @param string the synthetic value for display_mode (see a few
35 * lines above for explanations)
36 * @param integer the total number of rows returned by the SQL query
37 * without any programmatically appended "LIMIT" clause
38 * (just a copy of $unlim_num_rows if it exists, else
39 * computed inside this function)
41 * @return array an array with explicit indexes for all the display
42 * elements
44 * @global string the database name
45 * @global string the table name
46 * @global integer the total number of rows returned by the SQL query
47 * without any programmatically appended "LIMIT" clause
48 * @global array the properties of the fields returned by the query
49 * @global string the URL to return to in case of error in a SQL
50 * statement
52 * @access private
54 * @see PMA_displayTable()
56 function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
58 global $db, $table;
59 global $unlim_num_rows, $fields_meta;
60 global $err_url;
62 // 1. Initializes the $do_display array
63 $do_display = array();
64 $do_display['edit_lnk'] = $the_disp_mode[0] . $the_disp_mode[1];
65 $do_display['del_lnk'] = $the_disp_mode[2] . $the_disp_mode[3];
66 $do_display['sort_lnk'] = (string) $the_disp_mode[4];
67 $do_display['nav_bar'] = (string) $the_disp_mode[5];
68 $do_display['ins_row'] = (string) $the_disp_mode[6];
69 $do_display['bkm_form'] = (string) $the_disp_mode[7];
70 $do_display['text_btn'] = (string) $the_disp_mode[8];
71 $do_display['pview_lnk'] = (string) $the_disp_mode[9];
73 // 2. Display mode is not "false for all elements" -> updates the
74 // display mode
75 if ($the_disp_mode != 'nnnn000000') {
76 // 2.0 Print view -> set all elements to false!
77 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
78 $do_display['edit_lnk'] = 'nn'; // no edit link
79 $do_display['del_lnk'] = 'nn'; // no delete link
80 $do_display['sort_lnk'] = (string) '0';
81 $do_display['nav_bar'] = (string) '0';
82 $do_display['ins_row'] = (string) '0';
83 $do_display['bkm_form'] = (string) '0';
84 $do_display['text_btn'] = (string) '0';
85 $do_display['pview_lnk'] = (string) '0';
87 // 2.1 Statement is a "SELECT COUNT", a
88 // "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or
89 // contains a "PROC ANALYSE" part
90 elseif ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) {
91 $do_display['edit_lnk'] = 'nn'; // no edit link
92 $do_display['del_lnk'] = 'nn'; // no delete link
93 $do_display['sort_lnk'] = (string) '0';
94 $do_display['nav_bar'] = (string) '0';
95 $do_display['ins_row'] = (string) '0';
96 $do_display['bkm_form'] = (string) '1';
97 if ($GLOBALS['is_maint']) {
98 $do_display['text_btn'] = (string) '1';
99 } else {
100 $do_display['text_btn'] = (string) '0';
102 $do_display['pview_lnk'] = (string) '1';
104 // 2.2 Statement is a "SHOW..."
105 elseif ($GLOBALS['is_show']) {
107 * 2.2.1
108 * @todo defines edit/delete links depending on show statement
110 $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which);
111 if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
112 $do_display['edit_lnk'] = 'nn'; // no edit link
113 $do_display['del_lnk'] = 'kp'; // "kill process" type edit link
114 } else {
115 // Default case -> no links
116 $do_display['edit_lnk'] = 'nn'; // no edit link
117 $do_display['del_lnk'] = 'nn'; // no delete link
119 // 2.2.2 Other settings
120 $do_display['sort_lnk'] = (string) '0';
121 $do_display['nav_bar'] = (string) '0';
122 $do_display['ins_row'] = (string) '0';
123 $do_display['bkm_form'] = (string) '1';
124 $do_display['text_btn'] = (string) '1';
125 $do_display['pview_lnk'] = (string) '1';
127 // 2.3 Other statements (ie "SELECT" ones) -> updates
128 // $do_display['edit_lnk'], $do_display['del_lnk'] and
129 // $do_display['text_btn'] (keeps other default values)
130 else {
131 $prev_table = $fields_meta[0]->table;
132 $do_display['text_btn'] = (string) '1';
133 for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++) {
134 $is_link = ($do_display['edit_lnk'] != 'nn'
135 || $do_display['del_lnk'] != 'nn'
136 || $do_display['sort_lnk'] != '0'
137 || $do_display['ins_row'] != '0');
138 // 2.3.2 Displays edit/delete/sort/insert links?
139 if ($is_link
140 && ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) {
141 $do_display['edit_lnk'] = 'nn'; // don't display links
142 $do_display['del_lnk'] = 'nn';
144 * @todo May be problematic with same fields names in two joined table.
146 // $do_display['sort_lnk'] = (string) '0';
147 $do_display['ins_row'] = (string) '0';
148 if ($do_display['text_btn'] == '1') {
149 break;
151 } // end if (2.3.2)
152 // 2.3.3 Always display print view link
153 $do_display['pview_lnk'] = (string) '1';
154 $prev_table = $fields_meta[$i]->table;
155 } // end for
156 } // end if..elseif...else (2.1 -> 2.3)
157 } // end if (2)
159 // 3. Gets the total number of rows if it is unknown
160 if (isset($unlim_num_rows) && $unlim_num_rows != '') {
161 $the_total = $unlim_num_rows;
162 } elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1')
163 && (strlen($db) && !empty($table))) {
164 $the_total = PMA_Table::countRecords($db, $table, true);
167 // 4. If navigation bar or sorting fields names URLs should be
168 // displayed but there is only one row, change these settings to
169 // false
170 if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') {
172 // - Do not display sort links if less than 2 rows.
173 // - For a VIEW we (probably) did not count the number of rows
174 // so don't test this number here, it would remove the possibility
175 // of sorting VIEW results.
176 if (isset($unlim_num_rows) && $unlim_num_rows < 2 && ! PMA_Table::isView($db, $table)) {
177 // garvin: force display of navbar for vertical/horizontal display-choice.
178 // $do_display['nav_bar'] = (string) '0';
179 $do_display['sort_lnk'] = (string) '0';
181 } // end if (3)
183 // 5. Updates the synthetic var
184 $the_disp_mode = join('', $do_display);
186 return $do_display;
187 } // end of the 'PMA_setDisplayMode()' function
191 * Displays a navigation bar to browse among the results of a SQL query
193 * @uses $_SESSION['userconf']['disp_direction']
194 * @uses $_SESSION['userconf']['repeat_cells']
195 * @uses $_SESSION['userconf']['max_rows']
196 * @uses $_SESSION['userconf']['pos']
197 * @param integer the offset for the "next" page
198 * @param integer the offset for the "previous" page
199 * @param string the URL-encoded query
201 * @global string $db the database name
202 * @global string $table the table name
203 * @global string $goto the URL to go back in case of errors
204 * @global integer $num_rows the total number of rows returned by the
205 * SQL query
206 * @global integer $unlim_num_rows the total number of rows returned by the
207 * SQL any programmatically appended "LIMIT" clause
208 * @global boolean $is_innodb whether its InnoDB or not
209 * @global array $showtable table definitions
211 * @access private
213 * @see PMA_displayTable()
215 function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
217 global $db, $table, $goto;
218 global $num_rows, $unlim_num_rows;
219 global $is_innodb;
220 global $showtable;
222 // here, using htmlentities() would cause problems if the query
223 // contains accented characters
224 $html_sql_query = htmlspecialchars($sql_query);
227 * @todo move this to a central place
228 * @todo for other future table types
230 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
234 <!-- Navigation bar -->
235 <table border="0" cellpadding="2" cellspacing="0">
236 <tr>
237 <?php
238 // Move to the beginning or to the previous page
239 if ($_SESSION['userconf']['pos'] && $_SESSION['userconf']['max_rows'] != 'all') {
240 // loic1: patch #474210 from Gosha Sakovich - part 1
241 if ($GLOBALS['cfg']['NavigationBarIconic']) {
242 $caption1 = '&lt;&lt;';
243 $caption2 = ' &lt; ';
244 $title1 = ' title="' . $GLOBALS['strPos1'] . '"';
245 $title2 = ' title="' . $GLOBALS['strPrevious'] . '"';
246 } else {
247 $caption1 = $GLOBALS['strPos1'] . ' &lt;&lt;';
248 $caption2 = $GLOBALS['strPrevious'] . ' &lt;';
249 $title1 = '';
250 $title2 = '';
251 } // end if... else...
253 <td>
254 <form action="sql.php" method="post">
255 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
256 <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
257 <input type="hidden" name="pos" value="0" />
258 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
259 <input type="submit" name="navig" value="<?php echo $caption1; ?>"<?php echo $title1; ?> />
260 </form>
261 </td>
262 <td>
263 <form action="sql.php" method="post">
264 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
265 <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
266 <input type="hidden" name="pos" value="<?php echo $pos_prev; ?>" />
267 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
268 <input type="submit" name="navig" value="<?php echo $caption2; ?>"<?php echo $title2; ?> />
269 </form>
270 </td>
271 <?php
272 } // end move back
274 <td>
275 &nbsp;&nbsp;&nbsp;
276 </td>
277 <td align="center">
278 <?php // if displaying a VIEW, $unlim_num_rows could be zero because
279 // of $cfg['MaxExactCountViews']; in this case, avoid passing
280 // the 5th parameter to checkFormElementInRange()
281 // (this means we can't validate the upper limit ?>
282 <form action="sql.php" method="post"
283 onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 1) &amp;&amp; checkFormElementInRange(this, 'pos', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']); ?>', 0<?php echo $unlim_num_rows > 0 ? ',' . $unlim_num_rows - 1 : ''; ?>))">
284 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
285 <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
286 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
287 <input type="submit" name="navig" value="<?php echo $GLOBALS['strShow']; ?> :" />
288 <input type="text" name="session_max_rows" size="3" value="<?php echo (($_SESSION['userconf']['max_rows'] != 'all') ? $_SESSION['userconf']['max_rows'] : $GLOBALS['cfg']['MaxRows']); ?>" class="textfield" onfocus="this.select()" />
289 <?php echo $GLOBALS['strRowsFrom'] . "\n"; ?>
290 <input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
291 <br />
292 <?php
293 // Display mode (horizontal/vertical and repeat headers)
294 $param1 = ' <select name="disp_direction">' . "\n"
295 . ' <option value="horizontal"' . (($_SESSION['userconf']['disp_direction'] == 'horizontal') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
296 . ' <option value="horizontalflipped"' . (($_SESSION['userconf']['disp_direction'] == 'horizontalflipped') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeFlippedHorizontal'] . '</option>' . "\n"
297 . ' <option value="vertical"' . (($_SESSION['userconf']['disp_direction'] == 'vertical') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
298 . ' </select>' . "\n"
299 . ' ';
300 $param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $_SESSION['userconf']['repeat_cells'] . '" class="textfield" />' . "\n"
301 . ' ';
302 echo ' ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
304 </form>
305 </td>
306 <td>
307 &nbsp;&nbsp;&nbsp;
308 </td>
309 <?php
310 // Move to the next page or to the last one
311 if (($_SESSION['userconf']['pos'] + $_SESSION['userconf']['max_rows'] < $unlim_num_rows) && $num_rows >= $_SESSION['userconf']['max_rows']
312 && $_SESSION['userconf']['max_rows'] != 'all') {
313 // loic1: patch #474210 from Gosha Sakovich - part 2
314 if ($GLOBALS['cfg']['NavigationBarIconic']) {
315 $caption3 = ' &gt; ';
316 $caption4 = '&gt;&gt;';
317 $title3 = ' title="' . $GLOBALS['strNext'] . '"';
318 $title4 = ' title="' . $GLOBALS['strEnd'] . '"';
319 } else {
320 $caption3 = '&gt; ' . $GLOBALS['strNext'];
321 $caption4 = '&gt;&gt; ' . $GLOBALS['strEnd'];
322 $title3 = '';
323 $title4 = '';
324 } // end if... else...
325 echo "\n";
327 <td>
328 <form action="sql.php" method="post">
329 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
330 <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
331 <input type="hidden" name="pos" value="<?php echo $pos_next; ?>" />
332 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
333 <input type="submit" name="navig" value="<?php echo $caption3; ?>"<?php echo $title3; ?> />
334 </form>
335 </td>
336 <td>
337 <form action="sql.php" method="post"
338 onsubmit="return <?php echo (($_SESSION['userconf']['pos'] + $_SESSION['userconf']['max_rows'] < $unlim_num_rows && $num_rows >= $_SESSION['userconf']['max_rows']) ? 'true' : 'false'); ?>">
339 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
340 <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
341 <input type="hidden" name="pos" value="<?php echo @((ceil($unlim_num_rows / $_SESSION['userconf']['max_rows'])- 1) * $_SESSION['userconf']['max_rows']); ?>" />
342 <?php
343 if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
344 echo '<input type="hidden" name="find_real_end" value="1" />' . "\n";
345 // no backquote around this message
346 $onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], false) . '\')"';
349 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
350 <input type="submit" name="navig" value="<?php echo $caption4; ?>"<?php echo $title4; ?> <?php echo (empty($onclick) ? '' : $onclick); ?>/>
351 </form>
352 </td>
353 <?php
354 } // end move toward
357 //page redirection
358 // (unless we are showing all records)
359 if ('all' != $_SESSION['userconf']['max_rows']) { //if1
360 $pageNow = @floor($_SESSION['userconf']['pos'] / $_SESSION['userconf']['max_rows']) + 1;
361 $nbTotalPage = @ceil($unlim_num_rows / $_SESSION['userconf']['max_rows']);
363 if ($nbTotalPage > 1){ //if2
365 <td>
366 &nbsp;&nbsp;&nbsp;
367 </td>
368 <td>
369 <?php //<form> for keep the form alignment of button < and << ?>
370 <form action="none">
371 <?php echo PMA_pageselector(
372 'sql.php?sql_query=' . urlencode($sql_query) .
373 '&amp;goto=' . $goto .
374 '&amp;' . PMA_generate_common_url($db, $table) .
375 '&amp;',
376 $_SESSION['userconf']['max_rows'],
377 $pageNow,
378 $nbTotalPage,
379 200,
384 $GLOBALS['strPageNumber']
387 </form>
388 </td>
389 <?php
390 } //_if2
391 } //_if1
394 // Display the "Show all" button if allowed
395 if ($GLOBALS['cfg']['ShowAll'] && ($num_rows < $unlim_num_rows)) {
396 echo "\n";
398 <td>
399 &nbsp;&nbsp;&nbsp;
400 </td>
401 <td>
402 <form action="sql.php" method="post">
403 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
404 <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
405 <input type="hidden" name="pos" value="0" />
406 <input type="hidden" name="session_max_rows" value="all" />
407 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
408 <input type="submit" name="navig" value="<?php echo $GLOBALS['strShowAll']; ?>" />
409 </form>
410 </td>
411 <?php
412 } // end show all
413 echo "\n";
415 </tr>
416 </table>
418 <?php
419 } // end of the 'PMA_displayTableNavigation()' function
423 * Displays the headers of the results table
425 * @uses $_SESSION['userconf']['disp_direction']
426 * @uses $_SESSION['userconf']['repeat_cells']
427 * @uses $_SESSION['userconf']['max_rows']
428 * @uses $_SESSION['userconf']['dontlimitchars']
429 * @param array which elements to display
430 * @param array the list of fields properties
431 * @param integer the total number of fields returned by the SQL query
432 * @param array the analyzed query
434 * @return boolean always true
436 * @global string $db the database name
437 * @global string $table the table name
438 * @global string $goto the URL to go back in case of errors
439 * @global string $sql_query the SQL query
440 * @global integer $num_rows the total number of rows returned by the
441 * SQL query
442 * @global array $vertical_display informations used with vertical display
443 * mode
445 * @access private
447 * @see PMA_displayTable()
449 function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
451 global $db, $table, $goto;
452 global $sql_query, $num_rows;
453 global $vertical_display, $highlight_columns;
455 if ($analyzed_sql == '') {
456 $analyzed_sql = array();
459 // can the result be sorted?
460 if ($is_display['sort_lnk'] == '1') {
462 // Just as fallback
463 $unsorted_sql_query = $sql_query;
464 if (isset($analyzed_sql[0]['unsorted_query'])) {
465 $unsorted_sql_query = $analyzed_sql[0]['unsorted_query'];
468 // we need $sort_expression and $sort_expression_nodirection
469 // even if there are many table references
471 $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause']));
474 * Get rid of ASC|DESC
475 * @todo analyzer
477 preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches);
478 $sort_expression_nodirection = isset($matches[1]) ? trim($matches[1]) : $sort_expression;
480 // sorting by indexes, only if it makes sense (only one table ref)
481 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
482 isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
483 isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
485 // grab indexes data:
486 PMA_DBI_select_db($db);
487 if (!defined('PMA_IDX_INCLUDED')) {
488 $ret_keys = PMA_get_indexes($table);
491 $prev_index = '';
492 foreach ($ret_keys as $row) {
494 if ($row['Key_name'] != $prev_index){
495 $indexes[] = $row['Key_name'];
496 $prev_index = $row['Key_name'];
498 $indexes_info[$row['Key_name']]['Sequences'][] = $row['Seq_in_index'];
499 $indexes_info[$row['Key_name']]['Non_unique'] = $row['Non_unique'];
500 if (isset($row['Cardinality'])) {
501 $indexes_info[$row['Key_name']]['Cardinality'] = $row['Cardinality'];
503 // I don't know what does the following column mean....
504 // $indexes_info[$row['Key_name']]['Packed'] = $row['Packed'];
505 $indexes_info[$row['Key_name']]['Comment'] = (isset($row['Comment']))
506 ? $row['Comment']
507 : '';
508 $indexes_info[$row['Key_name']]['Index_type'] = (isset($row['Index_type']))
509 ? $row['Index_type']
510 : '';
512 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Column_name'] = $row['Column_name'];
513 if (isset($row['Sub_part'])) {
514 $indexes_data[$row['Key_name']][$row['Seq_in_index']]['Sub_part'] = $row['Sub_part'];
516 } // end while
518 // do we have any index?
519 if (isset($indexes_data)) {
521 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
522 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
523 $span = $fields_cnt;
524 if ($is_display['edit_lnk'] != 'nn') {
525 $span++;
527 if ($is_display['del_lnk'] != 'nn') {
528 $span++;
530 if ($is_display['del_lnk'] != 'kp' && $is_display['del_lnk'] != 'nn') {
531 $span++;
533 } else {
534 $span = $num_rows + floor($num_rows/$_SESSION['userconf']['repeat_cells']) + 1;
537 echo '<form action="sql.php" method="post">' . "\n";
538 echo PMA_generate_common_hidden_inputs($db, $table, 5);
539 echo $GLOBALS['strSortByKey'] . ': <select name="sql_query" onchange="this.form.submit();">' . "\n";
540 $used_index = false;
541 $local_order = (isset($sort_expression) ? $sort_expression : '');
542 foreach ($indexes_data AS $key => $val) {
543 $asc_sort = '';
544 $desc_sort = '';
545 foreach ($val AS $key2 => $val2) {
546 $asc_sort .= PMA_backquote($val2['Column_name']) . ' ASC , ';
547 $desc_sort .= PMA_backquote($val2['Column_name']) . ' DESC , ';
549 $asc_sort = substr($asc_sort, 0, -3);
550 $desc_sort = substr($desc_sort, 0, -3);
551 $used_index = $used_index || $local_order == $asc_sort || $local_order == $desc_sort;
552 echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $asc_sort) . '"' . ($local_order == $asc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strAscending'] . ')</option>';
553 echo "\n";
554 echo '<option value="' . htmlspecialchars($unsorted_sql_query . ' ORDER BY ' . $desc_sort) . '"' . ($local_order == $desc_sort ? ' selected="selected"' : '') . '>' . htmlspecialchars($key) . ' (' . $GLOBALS['strDescending'] . ')</option>';
555 echo "\n";
557 echo '<option value="' . htmlspecialchars($unsorted_sql_query) . '"' . ($used_index ? '' : ' selected="selected"') . '>' . $GLOBALS['strNone'] . '</option>';
558 echo "\n";
559 echo '</select>' . "\n";
560 echo '<noscript><input type="submit" value="' . $GLOBALS['strGo'] . '" /></noscript>';
561 echo "\n";
562 echo '</form>' . "\n";
568 $vertical_display['emptypre'] = 0;
569 $vertical_display['emptyafter'] = 0;
570 $vertical_display['textbtn'] = '';
573 // Start of form for multi-rows delete
575 if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') {
576 echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
577 echo PMA_generate_common_hidden_inputs($db, $table, 1);
578 echo '<input type="hidden" name="goto" value="sql.php" />' . "\n";
581 echo '<table id="table_results" class="data">' . "\n";
582 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
583 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
584 echo '<thead><tr>' . "\n";
587 // 1. Displays the full/partial text button (part 1)...
588 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
589 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
590 $colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
591 ? ' colspan="3"'
592 : '';
593 } else {
594 $rowspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
595 ? ' rowspan="3"'
596 : '';
598 $url_params = array(
599 'db' => $db,
600 'table' => $table,
601 'sql_query' => $sql_query,
602 'goto' => $goto,
604 $text_message = '<img class="fulltext" width="50" height="20"';
605 if ($_SESSION['userconf']['dontlimitchars']) {
606 $url_params['dontlimitchars'] = '0';
607 $text_message .= ''
608 . ' src="' . $GLOBALS['pmaThemeImage'] . 's_partialtext.png"'
609 . ' alt="' . $GLOBALS['strPartialText'] . '"'
610 . ' title="' . $GLOBALS['strPartialText'] . '"';
611 } else {
612 $url_params['dontlimitchars'] = '1';
613 $text_message .= ''
614 . ' src="' . $GLOBALS['pmaThemeImage'] . 's_fulltext.png"'
615 . ' alt="' . $GLOBALS['strFullText'] . '"'
616 . ' title="' . $GLOBALS['strFullText'] . '"';
618 $text_message .= ' />';
619 $text_url = 'sql.php' . PMA_generate_common_url($url_params);
620 $text_link = PMA_linkOrButton($text_url, $text_message, array(), false);
622 // ... before the result table
623 if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
624 && $is_display['text_btn'] == '1') {
625 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
626 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
627 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
629 <th colspan="<?php echo $fields_cnt; ?>"><?php echo $text_link; ?></th>
630 </tr>
631 <tr>
632 <?php
633 } // end horizontal/horizontalflipped mode
634 else {
636 <tr>
637 <th colspan="<?php echo $num_rows + floor($num_rows/$_SESSION['userconf']['repeat_cells']) + 1; ?>">
638 <?php echo $text_link; ?></th>
639 </tr>
640 <?php
641 } // end vertical mode
644 // ... at the left column of the result table header if possible
645 // and required
646 elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
647 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
648 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
649 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
651 <th <?php echo $colspan; ?>><?php echo $text_link; ?></th>
652 <?php
653 } // end horizontal/horizontalflipped mode
654 else {
655 $vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
656 . ' ' . $text_link . "\n"
657 . ' </th>' . "\n";
658 } // end vertical mode
661 // ... elseif no button, displays empty(ies) col(s) if required
662 elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft']
663 && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
664 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
665 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
666 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
668 <td<?php echo $colspan; ?>></td>
669 <?php
670 } // end horizontal/horizontalfipped mode
671 else {
672 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
673 } // end vertical mode
676 // 2. Displays the fields' name
677 // 2.0 If sorting links should be used, checks if the query is a "JOIN"
678 // statement (see 2.1.3)
680 // 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
681 // Do not show comments, if using horizontalflipped mode, because of space usage
682 if ($GLOBALS['cfg']['ShowBrowseComments']
683 && ($GLOBALS['cfgRelation']['commwork']
684 || PMA_MYSQL_INT_VERSION >= 40100)
685 && $_SESSION['userconf']['disp_direction'] != 'horizontalflipped') {
686 $comments_map = array();
687 if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
688 foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
689 $tb = $tbl['table_true_name'];
690 $comments_map[$tb] = PMA_getComments($db, $tb);
691 unset($tb);
696 if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
697 require_once './libraries/transformations.lib.php';
698 $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
701 if ($is_display['sort_lnk'] == '1') {
702 $select_expr = $analyzed_sql[0]['select_expr_clause'];
705 // garvin: See if we have to highlight any header fields of a WHERE query.
706 // Uses SQL-Parser results.
707 $highlight_columns = array();
708 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
709 isset($analyzed_sql[0]['where_clause_identifiers'])) {
711 $wi = 0;
712 if (isset($analyzed_sql[0]['where_clause_identifiers']) && is_array($analyzed_sql[0]['where_clause_identifiers'])) {
713 foreach ($analyzed_sql[0]['where_clause_identifiers'] AS $wci_nr => $wci) {
714 $highlight_columns[$wci] = 'true';
719 for ($i = 0; $i < $fields_cnt; $i++) {
720 // garvin: See if this column should get highlight because it's used in the
721 // where-query.
722 if (isset($highlight_columns[$fields_meta[$i]->name]) || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) {
723 $condition_field = true;
724 } else {
725 $condition_field = false;
728 // 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
729 if (isset($comments_map) &&
730 isset($comments_map[$fields_meta[$i]->table]) &&
731 isset($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name])) {
732 $comments = '<span class="tblcomment">' . htmlspecialchars($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name]) . '</span>';
733 } else {
734 $comments = '';
737 // 2.1 Results can be sorted
738 if ($is_display['sort_lnk'] == '1') {
740 // 2.1.1 Checks if the table name is required; it's the case
741 // for a query with a "JOIN" statement and if the column
742 // isn't aliased, or in queries like
743 // SELECT `1`.`master_field` , `2`.`master_field`
744 // FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
746 if (isset($fields_meta[$i]->table) && strlen($fields_meta[$i]->table)) {
747 $sort_tbl = PMA_backquote($fields_meta[$i]->table) . '.';
748 } else {
749 $sort_tbl = '';
752 // 2.1.2 Checks if the current column is used to sort the
753 // results
754 // the orgname member does not exist for all MySQL versions
755 // but if found, it's the one on which to sort
756 $name_to_use_in_sort = $fields_meta[$i]->name;
757 if (isset($fields_meta[$i]->orgname)) {
758 $name_to_use_in_sort = $fields_meta[$i]->orgname;
760 // $name_to_use_in_sort might contain a space due to
761 // formatting of function expressions like "COUNT(name )"
762 // so we remove the space in this situation
763 $name_to_use_in_sort = str_replace(' )', ')', $name_to_use_in_sort);
765 if (empty($sort_expression)) {
766 $is_in_sort = false;
767 } else {
768 // field name may be preceded by a space, or any number
769 // of characters followed by a dot (tablename.fieldname)
770 // so do a direct comparison
771 // for the sort expression (avoids problems with queries
772 // like "SELECT id, count(id)..." and clicking to sort
773 // on id or on count(id))
774 $is_in_sort = (str_replace('`', '', $sort_tbl) . $name_to_use_in_sort == str_replace('`', '', $sort_expression_nodirection) ? true : false);
776 // 2.1.3 Check the field name for a bracket.
777 // If it contains one, it's probably a function column
778 // like 'COUNT(`field`)'
780 if (strpos($name_to_use_in_sort, '(') !== false) {
781 $sort_order = ' ORDER BY ' . $name_to_use_in_sort . ' ';
782 } else {
783 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($name_to_use_in_sort) . ' ';
785 unset($name_to_use_in_sort);
787 // 2.1.4 Do define the sorting URL
788 if (! $is_in_sort) {
789 // loic1: patch #455484 ("Smart" order)
790 $GLOBALS['cfg']['Order'] = strtoupper($GLOBALS['cfg']['Order']);
791 if ($GLOBALS['cfg']['Order'] === 'SMART') {
792 $sort_order .= (preg_match('@time|date@i', $fields_meta[$i]->type)) ? 'DESC' : 'ASC';
793 } else {
794 $sort_order .= $GLOBALS['cfg']['Order'];
796 $order_img = '';
797 } elseif (preg_match('@[[:space:]]DESC$@i', $sort_expression)) {
798 $sort_order .= ' ASC';
799 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_desc.png" width="11" height="9" alt="'. $GLOBALS['strDescending'] . '" title="'. $GLOBALS['strDescending'] . '" id="soimg' . $i . '" />';
800 } else {
801 $sort_order .= ' DESC';
802 $order_img = ' <img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 's_asc.png" width="11" height="9" alt="'. $GLOBALS['strAscending'] . '" title="'. $GLOBALS['strAscending'] . '" id="soimg' . $i . '" />';
805 if (preg_match('@(.*)([[:space:]](LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE))@i', $unsorted_sql_query, $regs3)) {
806 $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
807 } else {
808 $sorted_sql_query = $unsorted_sql_query . $sort_order;
810 $url_query = PMA_generate_common_url($db, $table)
811 . '&amp;sql_query=' . urlencode($sorted_sql_query);
812 $order_url = 'sql.php?' . $url_query;
814 // 2.1.5 Displays the sorting URL
815 // added 20004-06-09: Michael Keck <mail@michaelkeck.de>
816 // enable sort order swapping for image
817 $order_link_params = array();
818 if (isset($order_img) && $order_img!='') {
819 if (strstr($order_img, 'asc')) {
820 $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
821 $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
822 } elseif (strstr($order_img, 'desc')) {
823 $order_link_params['onmouseover'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_asc.png\'; }';
824 $order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
827 if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped'
828 && $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
829 $order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;';
831 $order_link_params['title'] = $GLOBALS['strSort'];
832 $order_link_content = ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name));
833 $order_link = PMA_linkOrButton($order_url, $order_link_content . $order_img, $order_link_params, false, true);
835 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
836 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
837 echo '<th';
838 if ($condition_field) {
839 echo ' class="condition"';
841 if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
842 echo ' valign="bottom"';
844 echo '>' . $order_link . $comments . '</th>';
846 $vertical_display['desc'][] = ' <th '
847 . ($condition_field ? ' class="condition"' : '') . '>' . "\n"
848 . $order_link . $comments . ' </th>' . "\n";
849 } // end if (2.1)
851 // 2.2 Results can't be sorted
852 else {
853 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
854 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
855 echo '<th';
856 if ($condition_field) {
857 echo ' class="condition"';
859 if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
860 echo ' valign="bottom"';
862 if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped'
863 && $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
864 echo ' style="direction: ltr; writing-mode: tb-rl;"';
866 echo '>';
867 if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped'
868 && $GLOBALS['cfg']['HeaderFlipType'] == 'fake') {
869 echo PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), '<br />');
870 } else {
871 echo htmlspecialchars($fields_meta[$i]->name);
873 echo "\n" . $comments . '</th>';
875 $vertical_display['desc'][] = ' <th '
876 . ($condition_field ? ' class="condition"' : '') . '>' . "\n"
877 . ' ' . htmlspecialchars($fields_meta[$i]->name) . "\n"
878 . $comments . ' </th>';
879 } // end else (2.2)
880 } // end for
882 // 3. Displays the full/partial text button (part 2) at the right
883 // column of the result table header if possible and required...
884 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
885 && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')
886 && $is_display['text_btn'] == '1') {
887 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
888 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
889 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
890 echo "\n";
892 <th <?php echo $colspan; ?>>
893 <?php echo $text_link; ?>
894 </th>
895 <?php
896 } // end horizontal/horizontalflipped mode
897 else {
898 $vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n"
899 . ' ' . $text_link . "\n"
900 . ' </th>' . "\n";
901 } // end vertical mode
904 // ... elseif no button, displays empty columns if required
905 // (unless coming from Browse mode print view)
906 elseif ($GLOBALS['cfg']['ModifyDeleteAtRight']
907 && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
908 && (!$GLOBALS['is_header_sent'])) {
909 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
910 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
911 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
912 echo "\n";
914 <td<?php echo $colspan; ?>></td>
915 <?php
916 } // end horizontal/horizontalflipped mode
917 else {
918 $vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
919 } // end vertical mode
922 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
923 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
925 </tr>
926 </thead>
927 <?php
930 return true;
931 } // end of the 'PMA_displayTableHeaders()' function
936 * Displays the body of the results table
938 * @uses $_SESSION['userconf']['disp_direction']
939 * @uses $_SESSION['userconf']['repeat_cells']
940 * @uses $_SESSION['userconf']['max_rows']
941 * @uses $_SESSION['userconf']['dontlimitchars']
942 * @param integer the link id associated to the query which results have
943 * to be displayed
944 * @param array which elements to display
945 * @param array the list of relations
946 * @param array the analyzed query
948 * @return boolean always true
950 * @global string $db the database name
951 * @global string $table the table name
952 * @global string $goto the URL to go back in case of errors
953 * @global string $sql_query the SQL query
954 * @global array $fields_meta the list of fields properties
955 * @global integer $fields_cnt the total number of fields returned by
956 * the SQL query
957 * @global array $vertical_display informations used with vertical display
958 * mode
959 * @global array $highlight_columns column names to highlight
960 * @global array $row current row data
962 * @access private
964 * @see PMA_displayTable()
966 function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
967 global $db, $table, $goto;
968 global $sql_query, $fields_meta, $fields_cnt;
969 global $vertical_display, $highlight_columns;
970 global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin
972 $url_sql_query = $sql_query;
974 // query without conditions to shorten URLs when needed, 200 is just
975 // guess, it should depend on remaining URL length
977 if (isset($analyzed_sql) && isset($analyzed_sql[0]) &&
978 isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' &&
979 strlen($sql_query) > 200) {
981 $url_sql_query = 'SELECT ';
982 if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
983 $url_sql_query .= ' DISTINCT ';
985 $url_sql_query .= $analyzed_sql[0]['select_expr_clause'];
986 if (!empty($analyzed_sql[0]['from_clause'])) {
987 $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
991 if (!is_array($map)) {
992 $map = array();
994 $row_no = 0;
995 $vertical_display['edit'] = array();
996 $vertical_display['delete'] = array();
997 $vertical_display['data'] = array();
998 $vertical_display['row_delete'] = array();
1000 // Correction University of Virginia 19991216 in the while below
1001 // Previous code assumed that all tables have keys, specifically that
1002 // the phpMyAdmin GUI should support row delete/edit only for such
1003 // tables.
1004 // Although always using keys is arguably the prescribed way of
1005 // defining a relational table, it is not required. This will in
1006 // particular be violated by the novice.
1007 // We want to encourage phpMyAdmin usage by such novices. So the code
1008 // below has been changed to conditionally work as before when the
1009 // table being displayed has one or more keys; but to display
1010 // delete/edit options correctly for tables without keys.
1012 // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
1013 // to get the NULL values
1015 // rabus: This function needs a little rework.
1016 // Using MYSQL_BOTH just pollutes the memory!
1018 // ne0x: Use function PMA_DBI_fetch_array() due to mysqli
1019 // compatibility. Now this function is wrapped.
1021 $odd_row = true;
1022 while ($row = PMA_DBI_fetch_row($dt_result)) {
1023 // lem9: "vertical display" mode stuff
1024 if ($row_no != 0 && $_SESSION['userconf']['repeat_cells'] != 0 && !($row_no % $_SESSION['userconf']['repeat_cells'])
1025 && ($_SESSION['userconf']['disp_direction'] == 'horizontal'
1026 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped'))
1028 echo '<tr>' . "\n";
1029 if ($vertical_display['emptypre'] > 0) {
1030 echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n"
1031 .' &nbsp;</th>' . "\n";
1034 foreach ($vertical_display['desc'] as $val) {
1035 echo $val;
1038 if ($vertical_display['emptyafter'] > 0) {
1039 echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n"
1040 .' &nbsp;</th>' . "\n";
1042 echo '</tr>' . "\n";
1043 } // end if
1045 $class = $odd_row ? 'odd' : 'even';
1046 $odd_row = ! $odd_row;
1047 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
1048 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
1049 // loic1: pointer code part
1050 echo ' <tr class="' . $class . '">' . "\n";
1051 $class = '';
1055 // 1. Prepares the row (gets primary keys to use)
1056 // 1.1 Results from a "SELECT" statement -> builds the
1057 // "primary" key to use in links
1059 * @todo $unique_condition could be empty, for example a table
1060 * with only one field and it's a BLOB; in this case,
1061 * avoid to display the delete and edit links
1063 $unique_condition = urlencode(PMA_getUniqueCondition($dt_result, $fields_cnt, $fields_meta, $row));
1065 // 1.2 Defines the URLs for the modify/delete link(s)
1066 $url_query = PMA_generate_common_url($db, $table);
1068 if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
1069 // We need to copy the value or else the == 'both' check will always return true
1071 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1072 $iconic_spacer = '<div class="nowrap">';
1073 } else {
1074 $iconic_spacer = '';
1077 // 1.2.1 Modify link(s)
1078 if ($is_display['edit_lnk'] == 'ur') { // update row case
1079 $lnk_goto = 'sql.php';
1081 $edit_url = 'tbl_change.php'
1082 . '?' . $url_query
1083 . '&amp;primary_key=' . $unique_condition
1084 . '&amp;sql_query=' . urlencode($url_sql_query)
1085 . '&amp;goto=' . urlencode($lnk_goto);
1086 if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
1087 $edit_str = $GLOBALS['strEdit'];
1088 } else {
1089 $edit_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" />';
1090 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1091 $edit_str .= ' ' . $GLOBALS['strEdit'] . '</div>';
1094 } // end if (1.2.1)
1096 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])) {
1097 $bookmark_go = '<a href="import.php?'
1098 . PMA_generate_common_url($row[1], '')
1099 . '&amp;id_bookmark=' . $row[0]
1100 . '&amp;action_bookmark=0'
1101 . '&amp;action_bookmark_all=1'
1102 . '&amp;SQL=' . $GLOBALS['strExecuteBookmarked']
1103 .' " title="' . $GLOBALS['strExecuteBookmarked'] . '">';
1105 if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
1106 $bookmark_go .= $GLOBALS['strExecuteBookmarked'];
1107 } else {
1108 $bookmark_go .= $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" />';
1109 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1110 $bookmark_go .= ' ' . $GLOBALS['strExecuteBookmarked'] . '</div>';
1114 $bookmark_go .= '</a>';
1115 } else {
1116 $bookmark_go = '';
1119 // 1.2.2 Delete/Kill link(s)
1120 if ($is_display['del_lnk'] == 'dr') { // delete row case
1121 $lnk_goto = 'sql.php'
1122 . '?' . str_replace('&amp;', '&', $url_query)
1123 . '&sql_query=' . urlencode($url_sql_query)
1124 . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1125 . '&goto=' . (empty($goto) ? 'tbl_sql.php' : $goto);
1126 $del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $unique_condition . '+LIMIT+1';
1127 $del_url = 'sql.php'
1128 . '?' . $url_query
1129 . '&amp;sql_query=' . $del_query
1130 . '&amp;zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
1131 . '&amp;goto=' . urlencode($lnk_goto);
1132 $js_conf = 'DELETE FROM ' . PMA_jsFormat($table)
1133 . ' WHERE ' . trim(PMA_jsFormat(urldecode($unique_condition), false))
1134 . ' LIMIT 1';
1135 if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
1136 $del_str = $GLOBALS['strDelete'];
1137 } else {
1138 $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" />';
1139 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1140 $del_str .= ' ' . $GLOBALS['strDelete'] . '</div>';
1143 } elseif ($is_display['del_lnk'] == 'kp') { // kill process case
1144 $lnk_goto = 'sql.php'
1145 . '?' . str_replace('&amp;', '&', $url_query)
1146 . '&sql_query=' . urlencode($url_sql_query)
1147 . '&goto=main.php';
1148 $del_url = 'sql.php?'
1149 . PMA_generate_common_url('mysql')
1150 . '&amp;sql_query=' . urlencode('KILL ' . $row[0])
1151 . '&amp;goto=' . urlencode($lnk_goto);
1152 $del_query = urlencode('KILL ' . $row[0]);
1153 $js_conf = 'KILL ' . $row[0];
1154 if ($GLOBALS['cfg']['PropertiesIconic'] === false) {
1155 $del_str = $GLOBALS['strKill'];
1156 } else {
1157 $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" />';
1158 if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') {
1159 $del_str .= ' ' . $GLOBALS['strKill'] . '</div>';
1162 } // end if (1.2.2)
1164 // 1.3 Displays the links at left if required
1165 if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
1166 && ($_SESSION['userconf']['disp_direction'] == 'horizontal'
1167 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped')) {
1168 $doWriteModifyAt = 'left';
1169 require './libraries/display_tbl_links.lib.php';
1170 } // end if (1.3)
1171 } // end if (1)
1173 // 2. Displays the rows' values
1174 for ($i = 0; $i < $fields_cnt; ++$i) {
1175 $meta = $fields_meta[$i];
1176 // loic1: To fix bug #474943 under php4, the row pointer will
1177 // depend on whether the "is_null" php4 function is
1178 // available or not
1179 $pointer = (function_exists('is_null') ? $i : $meta->name);
1180 // garvin: See if this column should get highlight because it's used in the
1181 // where-query.
1182 if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) {
1183 $condition_field = true;
1184 } else {
1185 $condition_field = false;
1188 $mouse_events = '';
1189 if ($_SESSION['userconf']['disp_direction'] == 'vertical' && (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) {
1190 if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
1191 $mouse_events .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"'
1192 . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');" ';
1194 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
1195 $mouse_events .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
1196 } else {
1197 $mouse_events .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" ';
1199 }// end if
1201 // garvin: Wrap MIME-transformations. [MIME]
1202 $default_function = 'default_function'; // default_function
1203 $transform_function = $default_function;
1204 $transform_options = array();
1206 if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
1208 if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) {
1209 $include_file = PMA_sanitizeTransformationFile($GLOBALS['mime_map'][$meta->name]['transformation']);
1211 if (file_exists('./libraries/transformations/' . $include_file)) {
1212 $transformfunction_name = preg_replace('@(\.inc\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']);
1214 require_once './libraries/transformations/' . $include_file;
1216 if (function_exists('PMA_transformation_' . $transformfunction_name)) {
1217 $transform_function = 'PMA_transformation_' . $transformfunction_name;
1218 $transform_options = PMA_transformation_getOptions((isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : ''));
1219 $meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']);
1221 } // end if file_exists
1222 } // end if transformation is set
1223 } // end if mime/transformation works.
1225 $transform_options['wrapper_link'] = '?'
1226 . (isset($url_query) ? $url_query : '')
1227 . '&amp;primary_key=' . (isset($unique_condition) ? $unique_condition : '')
1228 . '&amp;sql_query=' . (empty($sql_query) ? '' : urlencode($url_sql_query))
1229 . '&amp;goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '')
1230 . '&amp;transform_key=' . urlencode($meta->name);
1233 // n u m e r i c
1234 if ($meta->numeric == 1) {
1237 // lem9: if two fields have the same name (this is possible
1238 // with self-join queries, for example), using $meta->name
1239 // will show both fields NULL even if only one is NULL,
1240 // so use the $pointer
1241 // (works only if function_exists('is_null')
1242 // PS: why not always work with the number ($i), since
1243 // the default second parameter of
1244 // mysql_fetch_array() is MYSQL_BOTH, so we always get
1245 // associative and numeric indices?
1247 //if (!isset($row[$meta->name])
1248 if (!isset($row[$i]) || is_null($row[$i])) {
1249 $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
1250 } elseif ($row[$i] != '') {
1251 $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . ' nowrap">';
1253 if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
1254 foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
1255 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1256 if (isset($alias) && strlen($alias)) {
1257 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1258 if ($alias == $meta->name) {
1259 $meta->name = $true_column;
1260 } // end if
1261 } // end if
1262 } // end while
1265 if (isset($map[$meta->name])) {
1266 // Field to display from the foreign table?
1267 if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
1268 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
1269 . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
1270 . ' WHERE ' . PMA_backquote($map[$meta->name][1])
1271 . ' = ' . $row[$i];
1272 $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
1273 if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
1274 list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
1275 } else {
1276 $dispval = $GLOBALS['strLinkNotFound'];
1278 @PMA_DBI_free_result($dispresult);
1279 } else {
1280 $dispval = '';
1281 } // end if... else...
1283 if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
1284 $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . ' <code>[-&gt;' . $dispval . ']</code>';
1285 } else {
1286 $title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
1288 $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
1289 . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
1290 . '&amp;pos=0'
1291 . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]) . '"' . $title . '>'
1292 . ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . '</a>';
1294 } else {
1295 $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta));
1297 $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1298 } else {
1299 $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ' nowrap' . ($condition_field ? ' condition' : '') . '">&nbsp;</td>' . "\n";
1302 // b l o b
1304 } elseif ($GLOBALS['cfg']['ShowBlob'] == false && stristr($meta->type, 'BLOB')) {
1305 // loic1 : PMA_mysql_fetch_fields returns BLOB in place of
1306 // TEXT fields type, however TEXT fields must be displayed
1307 // even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type
1308 // of the fields.
1309 $field_flags = PMA_DBI_field_flags($dt_result, $i);
1310 if (stristr($field_flags, 'BINARY')) {
1311 $blobtext = '[BLOB';
1312 if (!isset($row[$i]) || is_null($row[$i])) {
1313 $blobtext .= ' - NULL';
1314 $blob_size = 0;
1315 } elseif (isset($row[$i])) {
1316 $blob_size = strlen($row[$i]);
1317 $display_blob_size = PMA_formatByteDown($blob_size, 3, 1);
1318 $blobtext .= ' - '. $display_blob_size[0] . ' ' . $display_blob_size[1];
1319 unset($display_blob_size);
1322 $blobtext .= ']';
1323 if (strpos($transform_function, 'octetstream')) {
1324 $blobtext = $row[$i];
1326 if ($blob_size > 0) {
1327 $blobtext = ($default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta));
1329 unset($blob_size);
1331 $vertical_display['data'][$row_no][$i] = ' <td align="left"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $blobtext . '</td>';
1332 } else {
1333 if (!isset($row[$i]) || is_null($row[$i])) {
1334 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
1335 } elseif ($row[$i] != '') {
1336 // garvin: if a transform function for blob is set, none of these replacements will be made
1337 if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ! $_SESSION['userconf']['dontlimitchars']) {
1338 $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1340 // loic1: displays all space characters, 4 space
1341 // characters for tabulations and <cr>/<lf>
1342 $row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1344 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $row[$i] . '</td>' . "\n";
1345 } else {
1346 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">&nbsp;</td>' . "\n";
1349 } else {
1350 if (!isset($row[$i]) || is_null($row[$i])) {
1351 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
1352 } elseif ($row[$i] != '') {
1353 // loic1: support blanks in the key
1354 $relation_id = $row[$i];
1356 // nijel: Cut all fields to $GLOBALS['cfg']['LimitChars']
1357 // lem9: (unless it's a link-type transformation)
1358 if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ! $_SESSION['userconf']['dontlimitchars'] && !strpos($transform_function, 'link') === true) {
1359 $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
1362 // loic1: displays special characters from binaries
1363 $field_flags = PMA_DBI_field_flags($dt_result, $i);
1364 if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
1365 $row[$i] = PMA_printable_bit_value($row[$i], $meta->length);
1366 } elseif (stristr($field_flags, 'BINARY')) {
1367 $row[$i] = str_replace("\x00", '\0', $row[$i]);
1368 $row[$i] = str_replace("\x08", '\b', $row[$i]);
1369 $row[$i] = str_replace("\x0a", '\n', $row[$i]);
1370 $row[$i] = str_replace("\x0d", '\r', $row[$i]);
1371 $row[$i] = str_replace("\x1a", '\Z', $row[$i]);
1372 $row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1374 // loic1: displays all space characters, 4 space
1375 // characters for tabulations and <cr>/<lf>
1376 else {
1377 $row[$i] = ($default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta));
1380 // garvin: transform functions may enable no-wrapping:
1381 $function_nowrap = $transform_function . '_nowrap';
1382 $bool_nowrap = (($default_function != $transform_function && function_exists($function_nowrap)) ? $function_nowrap($transform_options) : false);
1384 // loic1: do not wrap if date field type
1385 $nowrap = ((preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap) ? ' nowrap' : '');
1386 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . $nowrap . ($condition_field ? ' condition' : '') . '">';
1388 if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
1389 foreach ($analyzed_sql[0]['select_expr'] AS $select_expr_position => $select_expr) {
1390 $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
1391 if (isset($alias) && strlen($alias)) {
1392 $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
1393 if ($alias == $meta->name) {
1394 $meta->name = $true_column;
1395 } // end if
1396 } // end if
1397 } // end while
1400 if (isset($map[$meta->name])) {
1401 // Field to display from the foreign table?
1402 if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
1403 $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
1404 . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
1405 . ' WHERE ' . PMA_backquote($map[$meta->name][1])
1406 . ' = \'' . PMA_sqlAddslashes($row[$i]) . '\'';
1407 $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
1408 if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
1409 list($dispval) = PMA_DBI_fetch_row($dispresult);
1410 @PMA_DBI_free_result($dispresult);
1411 } else {
1412 $dispval = $GLOBALS['strLinkNotFound'];
1414 } else {
1415 $dispval = '';
1417 $title = (!empty($dispval))? ' title="' . htmlspecialchars($dispval) . '"' : '';
1419 $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
1420 . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
1421 . '&amp;pos=0'
1422 . '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>'
1423 . $row[$i] . '</a>';
1424 } else {
1425 $vertical_display['data'][$row_no][$i] .= $row[$i];
1427 $vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
1428 } else {
1429 $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">&nbsp;</td>' . "\n";
1433 // lem9: output stored cell
1434 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
1435 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
1436 echo $vertical_display['data'][$row_no][$i];
1439 if (isset($vertical_display['rowdata'][$i][$row_no])) {
1440 $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i];
1441 } else {
1442 $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i];
1444 } // end for (2)
1446 // 3. Displays the modify/delete links on the right if required
1447 if ($GLOBALS['cfg']['ModifyDeleteAtRight']
1448 && ($_SESSION['userconf']['disp_direction'] == 'horizontal'
1449 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped')) {
1450 $doWriteModifyAt = 'right';
1451 require './libraries/display_tbl_links.lib.php';
1452 } // end if (3)
1454 if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
1455 || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
1457 </tr>
1458 <?php
1459 } // end if
1461 // 4. Gather links of del_urls and edit_urls in an array for later
1462 // output
1463 if (!isset($vertical_display['edit'][$row_no])) {
1464 $vertical_display['edit'][$row_no] = '';
1465 $vertical_display['delete'][$row_no] = '';
1466 $vertical_display['row_delete'][$row_no] = '';
1469 $column_style_vertical = '';
1470 if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
1471 $column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"'
1472 . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');"';
1474 $column_marker_vertical = '';
1475 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) {
1476 $column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\');';
1479 if (!empty($del_url) && $is_display['del_lnk'] != 'kp') {
1480 $vertical_display['row_delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
1481 . ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $unique_condition . ']"'
1482 . ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"'
1483 . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n"
1484 . ' </td>' . "\n";
1485 } else {
1486 unset($vertical_display['row_delete'][$row_no]);
1489 if (isset($edit_url)) {
1490 $vertical_display['edit'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
1491 . PMA_linkOrButton($edit_url, $edit_str, array(), false)
1492 . $bookmark_go
1493 . ' </td>' . "\n";
1494 } else {
1495 unset($vertical_display['edit'][$row_no]);
1498 if (isset($del_url)) {
1499 $vertical_display['delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n"
1500 . PMA_linkOrButton($del_url, $del_str, (isset($js_conf) ? $js_conf : ''), false)
1501 . ' </td>' . "\n";
1502 } else {
1503 unset($vertical_display['delete'][$row_no]);
1506 echo (($_SESSION['userconf']['disp_direction'] == 'horizontal' || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') ? "\n" : '');
1507 $row_no++;
1508 } // end while
1510 if (isset($url_query)) {
1511 $GLOBALS['url_query'] = $url_query;
1514 return true;
1515 } // end of the 'PMA_displayTableBody()' function
1519 * Do display the result table with the vertical direction mode.
1520 * Credits for this feature goes to Garvin Hicking <hicking@faktor-e.de>.
1522 * @return boolean always true
1524 * @uses $_SESSION['userconf']['repeat_cells']
1525 * @global array $vertical_display the information to display
1527 * @access private
1529 * @see PMA_displayTable()
1531 function PMA_displayVerticalTable()
1533 global $vertical_display;
1535 // Displays "multi row delete" link at top if required
1536 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
1537 echo '<tr>' . "\n";
1538 echo $vertical_display['textbtn'];
1539 $foo_counter = 0;
1540 foreach ($vertical_display['row_delete'] as $val) {
1541 if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
1542 echo '<th>&nbsp;</th>' . "\n";
1545 echo str_replace('[%_PMA_CHECKBOX_DIR_%]', '', $val);
1546 $foo_counter++;
1547 } // end while
1548 echo '</tr>' . "\n";
1549 } // end if
1551 // Displays "edit" link at top if required
1552 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
1553 echo '<tr>' . "\n";
1554 if (!is_array($vertical_display['row_delete'])) {
1555 echo $vertical_display['textbtn'];
1557 $foo_counter = 0;
1558 foreach ($vertical_display['edit'] as $val) {
1559 if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
1560 echo ' <th>&nbsp;</th>' . "\n";
1563 echo $val;
1564 $foo_counter++;
1565 } // end while
1566 echo '</tr>' . "\n";
1567 } // end if
1569 // Displays "delete" link at top if required
1570 if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
1571 echo '<tr>' . "\n";
1572 if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
1573 echo $vertical_display['textbtn'];
1575 $foo_counter = 0;
1576 foreach ($vertical_display['delete'] as $val) {
1577 if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
1578 echo '<th>&nbsp;</th>' . "\n";
1581 echo $val;
1582 $foo_counter++;
1583 } // end while
1584 echo '</tr>' . "\n";
1585 } // end if
1587 // Displays data
1588 foreach ($vertical_display['desc'] AS $key => $val) {
1590 echo '<tr>' . "\n";
1591 echo $val;
1593 $foo_counter = 0;
1594 foreach ($vertical_display['rowdata'][$key] as $subval) {
1595 if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) and !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
1596 echo $val;
1599 echo $subval;
1600 $foo_counter++;
1601 } // end while
1603 echo '</tr>' . "\n";
1604 } // end while
1606 // Displays "multi row delete" link at bottom if required
1607 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
1608 echo '<tr>' . "\n";
1609 echo $vertical_display['textbtn'];
1610 $foo_counter = 0;
1611 foreach ($vertical_display['row_delete'] as $val) {
1612 if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
1613 echo '<th>&nbsp;</th>' . "\n";
1616 echo str_replace('[%_PMA_CHECKBOX_DIR_%]', 'r', $val);
1617 $foo_counter++;
1618 } // end while
1619 echo '</tr>' . "\n";
1620 } // end if
1622 // Displays "edit" link at bottom if required
1623 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['edit']) && (count($vertical_display['edit']) > 0 || !empty($vertical_display['textbtn']))) {
1624 echo '<tr>' . "\n";
1625 if (!is_array($vertical_display['row_delete'])) {
1626 echo $vertical_display['textbtn'];
1628 $foo_counter = 0;
1629 foreach ($vertical_display['edit'] as $val) {
1630 if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
1631 echo '<th>&nbsp;</th>' . "\n";
1634 echo $val;
1635 $foo_counter++;
1636 } // end while
1637 echo '</tr>' . "\n";
1638 } // end if
1640 // Displays "delete" link at bottom if required
1641 if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && is_array($vertical_display['delete']) && (count($vertical_display['delete']) > 0 || !empty($vertical_display['textbtn']))) {
1642 echo '<tr>' . "\n";
1643 if (!is_array($vertical_display['edit']) && !is_array($vertical_display['row_delete'])) {
1644 echo $vertical_display['textbtn'];
1646 $foo_counter = 0;
1647 foreach ($vertical_display['delete'] as $val) {
1648 if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
1649 echo '<th>&nbsp;</th>' . "\n";
1652 echo $val;
1653 $foo_counter++;
1654 } // end while
1655 echo '</tr>' . "\n";
1658 return true;
1659 } // end of the 'PMA_displayVerticalTable' function
1663 * @uses $_SESSION['userconf']['disp_direction']
1664 * @uses $_REQUEST['disp_direction']
1665 * @uses $GLOBALS['cfg']['DefaultDisplay']
1666 * @uses $_SESSION['userconf']['repeat_cells']
1667 * @uses $_REQUEST['repeat_cells']
1668 * @uses $GLOBALS['cfg']['RepeatCells']
1669 * @uses $_SESSION['userconf']['max_rows']
1670 * @uses $_REQUEST['session_max_rows']
1671 * @uses $GLOBALS['cfg']['MaxRows']
1672 * @uses $_SESSION['userconf']['pos']
1673 * @uses $_REQUEST['pos']
1674 * @uses $_SESSION['userconf']['dontlimitchars']
1675 * @uses $_REQUEST['dontlimitchars']
1676 * @uses PMA_isValid()
1677 * @uses $GLOBALS['sql_query']
1678 * @todo make maximum remembered queries configurable
1679 * @todo move/split into SQL class!?
1680 * @todo currently this is called twice unnecessary
1681 * @todo ignore LIMIT and ORDER in query!?
1683 function PMA_displayTable_checkConfigParams()
1685 $sql_key = md5($GLOBALS['sql_query']);
1687 $_SESSION['userconf']['query'][$sql_key]['sql'] = $GLOBALS['sql_query'];
1689 if (PMA_isValid($_REQUEST['disp_direction'], array('horizontal', 'vertical', 'horizontalflipped'))) {
1690 $_SESSION['userconf']['query'][$sql_key]['disp_direction'] = $_REQUEST['disp_direction'];
1691 unset($_REQUEST['disp_direction']);
1692 } elseif (empty($_SESSION['userconf']['query'][$sql_key]['disp_direction'])) {
1693 $_SESSION['userconf']['query'][$sql_key]['disp_direction'] = $GLOBALS['cfg']['DefaultDisplay'];
1696 if (PMA_isValid($_REQUEST['repeat_cells'], 'numeric')) {
1697 $_SESSION['userconf']['query'][$sql_key]['repeat_cells'] = $_REQUEST['repeat_cells'];
1698 unset($_REQUEST['repeat_cells']);
1699 } elseif (empty($_SESSION['userconf']['query'][$sql_key]['repeat_cells'])) {
1700 $_SESSION['userconf']['query'][$sql_key]['repeat_cells'] = $GLOBALS['cfg']['RepeatCells'];
1703 if (PMA_isValid($_REQUEST['session_max_rows'], 'numeric') || $_REQUEST['session_max_rows'] == 'all') {
1704 $_SESSION['userconf']['query'][$sql_key]['max_rows'] = $_REQUEST['session_max_rows'];
1705 unset($_REQUEST['session_max_rows']);
1706 } elseif (empty($_SESSION['userconf']['query'][$sql_key]['max_rows'])) {
1707 $_SESSION['userconf']['query'][$sql_key]['max_rows'] = $GLOBALS['cfg']['MaxRows'];
1710 if (PMA_isValid($_REQUEST['pos'], 'numeric')) {
1711 $_SESSION['userconf']['query'][$sql_key]['pos'] = $_REQUEST['pos'];
1712 unset($_REQUEST['pos']);
1713 } elseif (empty($_SESSION['userconf']['query'][$sql_key]['pos'])) {
1714 $_SESSION['userconf']['query'][$sql_key]['pos'] = 0;
1717 if (PMA_isValid($_REQUEST['dontlimitchars'], array('0', '1'))) {
1718 $_SESSION['userconf']['query'][$sql_key]['dontlimitchars'] = (int) $_REQUEST['dontlimitchars'];
1719 unset($_REQUEST['dontlimitchars']);
1720 } elseif (empty($_SESSION['userconf']['query'][$sql_key]['dontlimitchars'])) {
1721 $_SESSION['userconf']['query'][$sql_key]['dontlimitchars'] = 0;
1724 // move current query to the last position, to be removed last
1725 // so only least executed query will be removed if maximum remembered queries
1726 // limit is reached
1727 $tmp = $_SESSION['userconf']['query'][$sql_key];
1728 unset($_SESSION['userconf']['query'][$sql_key]);
1729 $_SESSION['userconf']['query'][$sql_key] = $tmp;
1731 // do not exceed a maximum number of queries to remember
1732 if (count($_SESSION['userconf']['query']) > 10) {
1733 array_shift($_SESSION['userconf']['query']);
1734 //echo 'deleting one element ...';
1737 // populate query configuration
1738 $_SESSION['userconf']['dontlimitchars'] = $_SESSION['userconf']['query'][$sql_key]['dontlimitchars'];
1739 $_SESSION['userconf']['pos'] = $_SESSION['userconf']['query'][$sql_key]['pos'];
1740 $_SESSION['userconf']['max_rows'] = $_SESSION['userconf']['query'][$sql_key]['max_rows'];
1741 $_SESSION['userconf']['repeat_cells'] = $_SESSION['userconf']['query'][$sql_key]['repeat_cells'];
1742 $_SESSION['userconf']['disp_direction'] = $_SESSION['userconf']['query'][$sql_key]['disp_direction'];
1745 * debugging
1746 echo '<pre>';
1747 var_dump($_SESSION['userconf']);
1748 echo '</pre>';
1753 * Displays a table of results returned by a SQL query.
1754 * This function is called by the "sql.php" script.
1756 * @param integer the link id associated to the query which results have
1757 * to be displayed
1758 * @param array the display mode
1759 * @param array the analyzed query
1761 * @uses $_SESSION['userconf']['pos']
1762 * @global string $db the database name
1763 * @global string $table the table name
1764 * @global string $goto the URL to go back in case of errors
1765 * @global string $sql_query the current SQL query
1766 * @global integer $num_rows the total number of rows returned by the
1767 * SQL query
1768 * @global integer $unlim_num_rows the total number of rows returned by the
1769 * SQL query without any programmatically
1770 * appended "LIMIT" clause
1771 * @global array $fields_meta the list of fields properties
1772 * @global integer $fields_cnt the total number of fields returned by
1773 * the SQL query
1774 * @global array $vertical_display informations used with vertical display
1775 * mode
1776 * @global array $highlight_columns column names to highlight
1777 * @global array $cfgRelation the relation settings
1779 * @access private
1781 * @see PMA_showMessage(), PMA_setDisplayMode(),
1782 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
1783 * PMA_displayTableBody(), PMA_displayResultsOperations()
1785 function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
1787 global $db, $table, $goto;
1788 global $sql_query, $num_rows, $unlim_num_rows, $fields_meta, $fields_cnt;
1789 global $vertical_display, $highlight_columns;
1790 global $cfgRelation;
1791 global $showtable;
1793 PMA_displayTable_checkConfigParams();
1796 * @todo move this to a central place
1797 * @todo for other future table types
1799 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
1801 if ($is_innodb
1802 && ! isset($analyzed_sql[0]['queryflags']['union'])
1803 && ! isset($analyzed_sql[0]['table_ref'][1]['table_name'])
1804 && (empty($analyzed_sql[0]['where_clause'])
1805 || $analyzed_sql[0]['where_clause'] == '1 ')) {
1806 // "j u s t b r o w s i n g"
1807 $pre_count = '~';
1808 $after_count = '[sup]1[/sup]';
1809 } else {
1810 $pre_count = '';
1811 $after_count = '';
1814 // 1. ----- Prepares the work -----
1816 // 1.1 Gets the informations about which functionalities should be
1817 // displayed
1818 $total = '';
1819 $is_display = PMA_setDisplayMode($the_disp_mode, $total);
1821 // 1.2 Defines offsets for the next and previous pages
1822 if ($is_display['nav_bar'] == '1') {
1823 if ($_SESSION['userconf']['max_rows'] == 'all') {
1824 $pos_next = 0;
1825 $pos_prev = 0;
1826 } else {
1827 $pos_next = $_SESSION['userconf']['pos'] + $_SESSION['userconf']['max_rows'];
1828 $pos_prev = $_SESSION['userconf']['pos'] - $_SESSION['userconf']['max_rows'];
1829 if ($pos_prev < 0) {
1830 $pos_prev = 0;
1833 } // end if
1835 // 1.3 URL-encodes the query to use in input form fields
1836 $encoded_sql_query = urlencode($sql_query);
1838 // 2. ----- Displays the top of the page -----
1840 // 2.1 Displays a messages with position informations
1841 if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
1842 if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
1843 $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
1844 } else {
1845 $selectstring = '';
1847 $last_shown_rec = ($_SESSION['userconf']['max_rows'] == 'all' || $pos_next > $total)
1848 ? $total - 1
1849 : $pos_next - 1;
1850 PMA_showMessage($GLOBALS['strShowingRecords'] . ' ' . $_SESSION['userconf']['pos'] . ' - ' . $last_shown_rec . ' (' . $pre_count . PMA_formatNumber($total, 0) . $after_count . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
1852 if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) {
1853 echo '<div class="notice">' . "\n";
1854 echo PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n";
1855 echo '</div>' . "\n";
1857 if ($pre_count) {
1858 echo '<div class="notice">' . "\n";
1859 echo '<sup>1</sup>' . PMA_sanitize($GLOBALS['strApproximateCount']) . "\n";
1860 echo '</div>' . "\n";
1863 } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1864 PMA_showMessage($GLOBALS['strSQLQuery']);
1867 // 2.3 Displays the navigation bars
1868 if (! strlen($table)) {
1869 if (isset($analyzed_sql[0]['query_type'])
1870 && $analyzed_sql[0]['query_type'] == 'SELECT') {
1871 // table does not always contain a real table name,
1872 // for example in MySQL 5.0.x, the query SHOW STATUS
1873 // returns STATUS as a table name
1874 $table = $fields_meta[0]->table;
1875 } else {
1876 $table = '';
1880 if ($is_display['nav_bar'] == '1') {
1881 PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query);
1882 echo "\n";
1883 } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
1884 echo "\n" . '<br /><br />' . "\n";
1887 // 2b ----- Get field references from Database -----
1888 // (see the 'relation' configuration variable)
1889 // loic1, 2002-03-02: extended to php3
1891 // initialize map
1892 $map = array();
1894 // find tables
1895 $target=array();
1896 if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) {
1897 foreach ($analyzed_sql[0]['table_ref'] AS $table_ref_position => $table_ref) {
1898 $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name'];
1901 $tabs = '(\'' . join('\',\'', $target) . '\')';
1903 if ($cfgRelation['displaywork']) {
1904 if (! strlen($table)) {
1905 $exist_rel = false;
1906 } else {
1907 $exist_rel = PMA_getForeigners($db, $table, '', 'both');
1908 if ($exist_rel) {
1909 foreach ($exist_rel AS $master_field => $rel) {
1910 $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']);
1911 $map[$master_field] = array($rel['foreign_table'],
1912 $rel['foreign_field'],
1913 $display_field,
1914 $rel['foreign_db']);
1915 } // end while
1916 } // end if
1917 } // end if
1918 } // end if
1919 // end 2b
1921 // 3. ----- Displays the results table -----
1922 PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql);
1923 $url_query='';
1924 echo '<tbody>' . "\n";
1925 PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
1926 // vertical output case
1927 if ($_SESSION['userconf']['disp_direction'] == 'vertical') {
1928 PMA_displayVerticalTable();
1929 } // end if
1930 unset($vertical_display);
1931 echo '</tbody>' . "\n";
1933 </table>
1935 <?php
1936 // 4. ----- Displays the link for multi-fields delete
1938 if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') {
1940 $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill'];
1942 $uncheckall_url = 'sql.php?'
1943 . PMA_generate_common_url($db, $table)
1944 . '&amp;sql_query=' . urlencode($sql_query)
1945 . '&amp;goto=' . $goto;
1946 $checkall_url = $uncheckall_url . '&amp;checkall=1';
1948 if ($_SESSION['userconf']['disp_direction'] == 'vertical') {
1949 $checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;';
1950 $uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;';
1951 } else {
1952 $checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;';
1953 $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;';
1955 $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
1956 $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
1957 if ($_SESSION['userconf']['disp_direction'] != 'vertical') {
1958 echo '<img class="selectallarrow" width="38" height="22"'
1959 .' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"'
1960 .' alt="' . $GLOBALS['strWithChecked'] . '" />';
1962 echo $checkall_link . "\n"
1963 .' / ' . "\n"
1964 .$uncheckall_link . "\n"
1965 .'<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n";
1967 if ($GLOBALS['cfg']['PropertiesIconic']) {
1968 PMA_buttonOrImage('submit_mult', 'mult_submit',
1969 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png');
1970 PMA_buttonOrImage('submit_mult', 'mult_submit',
1971 'submit_mult_delete', $delete_text, 'b_drop.png');
1972 if ($analyzed_sql[0]['querytype'] == 'SELECT') {
1973 PMA_buttonOrImage('submit_mult', 'mult_submit',
1974 'submit_mult_export', $GLOBALS['strExport'],
1975 'b_tblexport.png');
1977 echo "\n";
1978 } else {
1979 echo ' <input type="submit" name="submit_mult"'
1980 .' value="' . htmlspecialchars($GLOBALS['strEdit']) . '"'
1981 .' title="' . $GLOBALS['strEdit'] . '" />' . "\n";
1982 echo ' <input type="submit" name="submit_mult"'
1983 .' value="' . htmlspecialchars($delete_text) . '"'
1984 .' title="' . $delete_text . '" />' . "\n";
1985 if ($analyzed_sql[0]['querytype'] == 'SELECT') {
1986 echo ' <input type="submit" name="submit_mult"'
1987 .' value="' . htmlspecialchars($GLOBALS['strExport']) . '"'
1988 .' title="' . $GLOBALS['strExport'] . '" />' . "\n";
1991 echo '<input type="hidden" name="sql_query"'
1992 .' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
1993 echo '<input type="hidden" name="url_query"'
1994 .' value="' . $GLOBALS['url_query'] . '" />' . "\n";
1995 echo '</form>' . "\n";
1998 // 5. ----- Displays the navigation bar at the bottom if required -----
2000 if ($is_display['nav_bar'] == '1') {
2001 echo '<br />' . "\n";
2002 PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query);
2003 } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
2004 echo "\n" . '<br /><br />' . "\n";
2007 // 6. ----- Displays "Query results operations"
2008 if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
2009 PMA_displayResultsOperations($the_disp_mode, $analyzed_sql);
2011 } // end of the 'PMA_displayTable()' function
2013 function default_function($buffer) {
2014 $buffer = htmlspecialchars($buffer);
2015 $buffer = str_replace("\011", ' &nbsp;&nbsp;&nbsp;',
2016 str_replace(' ', ' &nbsp;', $buffer));
2017 $buffer = preg_replace("@((\015\012)|(\015)|(\012))@", '<br />', $buffer);
2019 return $buffer;
2023 * Displays operations that are available on results.
2025 * @param array the display mode
2026 * @param array the analyzed query
2028 * @uses $_SESSION['userconf']['pos']
2029 * @uses $_SESSION['userconf']['dontlimitchars']
2030 * @global string $db the database name
2031 * @global string $table the table name
2032 * @global string $sql_query the current SQL query
2033 * @global integer $unlim_num_rows the total number of rows returned by the
2034 * SQL query without any programmatically
2035 * appended "LIMIT" clause
2037 * @access private
2039 * @see PMA_showMessage(), PMA_setDisplayMode(),
2040 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
2041 * PMA_displayTableBody(), PMA_displayResultsOperations()
2043 function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
2044 global $db, $table, $sql_query, $unlim_num_rows;
2046 $header_shown = FALSE;
2047 $header = '<fieldset><legend>' . $GLOBALS['strQueryResultsOperations'] . '</legend>';
2049 if ($the_disp_mode[6] == '1' || $the_disp_mode[9] == '1') {
2050 // Displays "printable view" link if required
2051 if ($the_disp_mode[9] == '1') {
2053 if (!$header_shown) {
2054 echo $header;
2055 $header_shown = TRUE;
2058 $url_query = '?'
2059 . PMA_generate_common_url($db, $table)
2060 . '&amp;printview=1'
2061 . '&amp;sql_query=' . urlencode($sql_query);
2062 echo ' <!-- Print view -->' . "\n";
2063 echo PMA_linkOrButton(
2064 'sql.php' . $url_query,
2065 ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_print.png" height="16" width="16" alt="' . $GLOBALS['strPrintView'] . '"/>' : '') . $GLOBALS['strPrintView'],
2066 '', true, true, 'print_view') . "\n";
2068 if (! $_SESSION['userconf']['dontlimitchars']) {
2069 echo ' &nbsp;&nbsp;' . "\n";
2070 echo PMA_linkOrButton(
2071 'sql.php' . $url_query . '&amp;dontlimitchars=1',
2072 ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_print.png" height="16" width="16" alt="' . $GLOBALS['strPrintViewFull'] . '"/>' : '') . $GLOBALS['strPrintViewFull'],
2073 '', true, true, 'print_view') . "\n";
2075 } // end displays "printable view"
2077 echo "\n";
2080 // Export link
2081 // (the url_query has extra parameters that won't be used to export)
2082 // (the single_table parameter is used in display_export.lib.php
2083 // to hide the SQL and the structure export dialogs)
2084 // If the parser found a PROCEDURE clause
2085 // (most probably PROCEDURE ANALYSE()) it makes no sense to
2086 // display the Export link).
2088 if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT' && !isset($printview) && ! isset($analyzed_sql[0]['queryflags']['procedure'])) {
2089 if (isset($analyzed_sql[0]['table_ref'][0]['table_true_name']) && !isset($analyzed_sql[0]['table_ref'][1]['table_true_name'])) {
2090 $single_table = '&amp;single_table=true';
2091 } else {
2092 $single_table = '';
2094 if (!$header_shown) {
2095 echo $header;
2096 $header_shown = TRUE;
2098 echo ' <!-- Export -->' . "\n";
2099 echo ' &nbsp;&nbsp;' . "\n";
2100 echo PMA_linkOrButton(
2101 'tbl_export.php' . $url_query . '&amp;unlim_num_rows=' . $unlim_num_rows . $single_table,
2102 ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_tblexport.png" height="16" width="16" alt="' . $GLOBALS['strExport'] . '" />' : '') . $GLOBALS['strExport'],
2103 '', true, true, '') . "\n";
2106 // CREATE VIEW
2109 * @todo detect privileges to create a view
2110 * (but see 2006-01-19 note in display_create_table.lib.php,
2111 * I think we cannot detect db-specific privileges reliably)
2112 * Note: we don't display a Create view link if we found a PROCEDURE clause
2114 if (PMA_MYSQL_INT_VERSION >= 50000 && ! isset($analyzed_sql[0]['queryflags']['procedure'])) {
2115 if (!$header_shown) {
2116 echo $header;
2117 $header_shown = TRUE;
2119 echo ' <!-- Create View -->' . "\n";
2120 echo ' &nbsp;&nbsp;' . "\n";
2121 echo PMA_linkOrButton(
2122 'view_create.php' . $url_query,
2123 ($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_views.png" height="16" width="16" alt="CREATE VIEW" />' : '') . 'CREATE VIEW',
2124 '', true, true, '') . "\n";
2127 if ($header_shown) {
2128 echo '</fieldset><br />';