diff --git a/htdocs/sql/libraries/display_tbl.lib.php b/htdocs/sql/libraries/display_tbl.lib.php new file mode 100755 --- /dev/null +++ b/htdocs/sql/libraries/display_tbl.lib.php @@ -0,0 +1,2131 @@ + updates the + // display mode + if ($the_disp_mode != 'nnnn000000') { + // 2.0 Print view -> set all elements to false! + if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') { + $do_display['edit_lnk'] = 'nn'; // no edit link + $do_display['del_lnk'] = 'nn'; // no delete link + $do_display['sort_lnk'] = (string) '0'; + $do_display['nav_bar'] = (string) '0'; + $do_display['ins_row'] = (string) '0'; + $do_display['bkm_form'] = (string) '0'; + $do_display['text_btn'] = (string) '0'; + $do_display['pview_lnk'] = (string) '0'; + } + // 2.1 Statement is a "SELECT COUNT", a + // "CHECK/ANALYZE/REPAIR/OPTIMIZE", an "EXPLAIN" one or + // contains a "PROC ANALYSE" part + elseif ($GLOBALS['is_count'] || $GLOBALS['is_analyse'] || $GLOBALS['is_maint'] || $GLOBALS['is_explain']) { + $do_display['edit_lnk'] = 'nn'; // no edit link + $do_display['del_lnk'] = 'nn'; // no delete link + $do_display['sort_lnk'] = (string) '0'; + $do_display['nav_bar'] = (string) '0'; + $do_display['ins_row'] = (string) '0'; + $do_display['bkm_form'] = (string) '1'; + if ($GLOBALS['is_maint']) { + $do_display['text_btn'] = (string) '1'; + } else { + $do_display['text_btn'] = (string) '0'; + } + $do_display['pview_lnk'] = (string) '1'; + } + // 2.2 Statement is a "SHOW..." + elseif ($GLOBALS['is_show']) { + /** + * 2.2.1 + * @todo defines edit/delete links depending on show statement + */ + $tmp = preg_match('@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS)@i', $GLOBALS['sql_query'], $which); + if (isset($which[1]) && strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) { + $do_display['edit_lnk'] = 'nn'; // no edit link + $do_display['del_lnk'] = 'kp'; // "kill process" type edit link + } else { + // Default case -> no links + $do_display['edit_lnk'] = 'nn'; // no edit link + $do_display['del_lnk'] = 'nn'; // no delete link + } + // 2.2.2 Other settings + $do_display['sort_lnk'] = (string) '0'; + $do_display['nav_bar'] = (string) '0'; + $do_display['ins_row'] = (string) '0'; + $do_display['bkm_form'] = (string) '1'; + $do_display['text_btn'] = (string) '1'; + $do_display['pview_lnk'] = (string) '1'; + } + // 2.3 Other statements (ie "SELECT" ones) -> updates + // $do_display['edit_lnk'], $do_display['del_lnk'] and + // $do_display['text_btn'] (keeps other default values) + else { + $prev_table = $fields_meta[0]->table; + $do_display['text_btn'] = (string) '1'; + for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++) { + $is_link = ($do_display['edit_lnk'] != 'nn' + || $do_display['del_lnk'] != 'nn' + || $do_display['sort_lnk'] != '0' + || $do_display['ins_row'] != '0'); + // 2.3.2 Displays edit/delete/sort/insert links? + if ($is_link + && ($fields_meta[$i]->table == '' || $fields_meta[$i]->table != $prev_table)) { + $do_display['edit_lnk'] = 'nn'; // don't display links + $do_display['del_lnk'] = 'nn'; + /** + * @todo May be problematic with same fields names in two joined table. + */ + // $do_display['sort_lnk'] = (string) '0'; + $do_display['ins_row'] = (string) '0'; + if ($do_display['text_btn'] == '1') { + break; + } + } // end if (2.3.2) + // 2.3.3 Always display print view link + $do_display['pview_lnk'] = (string) '1'; + $prev_table = $fields_meta[$i]->table; + } // end for + } // end if..elseif...else (2.1 -> 2.3) + } // end if (2) + + // 3. Gets the total number of rows if it is unknown + if (isset($unlim_num_rows) && $unlim_num_rows != '') { + $the_total = $unlim_num_rows; + } elseif (($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') + && (strlen($db) && !empty($table))) { + $the_total = PMA_Table::countRecords($db, $table, true); + } + + // 4. If navigation bar or sorting fields names URLs should be + // displayed but there is only one row, change these settings to + // false + if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') { + + // - Do not display sort links if less than 2 rows. + // - For a VIEW we (probably) did not count the number of rows + // so don't test this number here, it would remove the possibility + // of sorting VIEW results. + if (isset($unlim_num_rows) && $unlim_num_rows < 2 && ! PMA_Table::isView($db, $table)) { + // garvin: force display of navbar for vertical/horizontal display-choice. + // $do_display['nav_bar'] = (string) '0'; + $do_display['sort_lnk'] = (string) '0'; + } + } // end if (3) + + // 5. Updates the synthetic var + $the_disp_mode = join('', $do_display); + + return $do_display; +} // end of the 'PMA_setDisplayMode()' function + + +/** + * Displays a navigation bar to browse among the results of a SQL query + * + * @uses $_SESSION['userconf']['disp_direction'] + * @uses $_SESSION['userconf']['repeat_cells'] + * @uses $_SESSION['userconf']['max_rows'] + * @uses $_SESSION['userconf']['pos'] + * @param integer the offset for the "next" page + * @param integer the offset for the "previous" page + * @param string the URL-encoded query + * + * @global string $db the database name + * @global string $table the table name + * @global string $goto the URL to go back in case of errors + * @global integer $num_rows the total number of rows returned by the + * SQL query + * @global integer $unlim_num_rows the total number of rows returned by the + * SQL any programmatically appended "LIMIT" clause + * @global boolean $is_innodb whether its InnoDB or not + * @global array $showtable table definitions + * + * @access private + * + * @see PMA_displayTable() + */ +function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query) +{ + global $db, $table, $goto; + global $num_rows, $unlim_num_rows; + global $is_innodb; + global $showtable; + + // here, using htmlentities() would cause problems if the query + // contains accented characters + $html_sql_query = htmlspecialchars($sql_query); + + /** + * @todo move this to a central place + * @todo for other future table types + */ + $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB'); + + ?> + + +
+ + | ++ + | + ++ + | ++ + + | ++ + | + = $_SESSION['userconf']['max_rows'] + && $_SESSION['userconf']['max_rows'] != 'all') { + // loic1: patch #474210 from Gosha Sakovich - part 2 + if ($GLOBALS['cfg']['NavigationBarIconic']) { + $caption3 = ' > '; + $caption4 = '>>'; + $title3 = ' title="' . $GLOBALS['strNext'] . '"'; + $title4 = ' title="' . $GLOBALS['strEnd'] . '"'; + } else { + $caption3 = '> ' . $GLOBALS['strNext']; + $caption4 = '>> ' . $GLOBALS['strEnd']; + $title3 = ''; + $title4 = ''; + } // end if... else... + echo "\n"; + ?> ++ + | ++ + | + 1){ //if2 + ?> ++ + | ++ for keep the form alignment of button < and << ?> + + | + ++ + | ++ + | + +