display_tbl.lib.php
来自「phpMyAdmin图形界面化操作,我已经配置好了,只要把解要压缩后的文件放到站」· PHP 代码 · 共 1,349 行 · 第 1/5 页
PHP
1,349 行
<?php/* vim: set expandtab sw=4 ts=4 sts=4: *//** * library for displaying table with results from all sort of select queries * * @version $Id: display_tbl.lib.php 12008 2008-11-27 21:19:22Z lem9 $ *//** * */require_once './libraries/Table.class.php';require_once './libraries/Index.class.php';/** * Defines the display mode to use for the results of a SQL query * * It uses a synthetic string that contains all the required informations. * In this string: * - the first two characters stand for the action to do while * clicking on the "edit" link (e.g. 'ur' for update a row, 'nn' for no * edit link...); * - the next two characters stand for the action to do while * clicking on the "delete" link (e.g. 'kp' for kill a process, 'nn' for * no delete link...); * - the next characters are boolean values (1/0) and respectively stand * for sorting links, navigation bar, "insert a new row" link, the * bookmark feature, the expand/collapse text/blob fields button and * the "display printable view" option. * Of course '0'/'1' means the feature won't/will be enabled. * * @param string the synthetic value for display_mode (see a few * lines above for explanations) * @param integer the total number of rows returned by the SQL query * without any programmatically appended "LIMIT" clause * (just a copy of $unlim_num_rows if it exists, else * computed inside this function) * * @return array an array with explicit indexes for all the display * elements * * @global string the database name * @global string the table name * @global integer the total number of rows returned by the SQL query * without any programmatically appended "LIMIT" clause * @global array the properties of the fields returned by the query * @global string the URL to return to in case of error in a SQL * statement * * @access private * * @see PMA_displayTable() */function PMA_setDisplayMode(&$the_disp_mode, &$the_total){ global $db, $table; global $unlim_num_rows, $fields_meta; global $err_url; // 1. Initializes the $do_display array $do_display = array(); $do_display['edit_lnk'] = $the_disp_mode[0] . $the_disp_mode[1]; $do_display['del_lnk'] = $the_disp_mode[2] . $the_disp_mode[3]; $do_display['sort_lnk'] = (string) $the_disp_mode[4]; $do_display['nav_bar'] = (string) $the_disp_mode[5]; $do_display['ins_row'] = (string) $the_disp_mode[6]; $do_display['bkm_form'] = (string) $the_disp_mode[7]; $do_display['text_btn'] = (string) $the_disp_mode[8]; $do_display['pview_lnk'] = (string) $the_disp_mode[9]; // 2. Display mode is not "false for all elements" -> 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'); ?><!-- Navigation bar --><table border="0" cellpadding="2" cellspacing="0"><tr> <?php // Move to the beginning or to the previous page if ($_SESSION['userconf']['pos'] && $_SESSION['userconf']['max_rows'] != 'all') { // loic1: patch #474210 from Gosha Sakovich - part 1 if ($GLOBALS['cfg']['NavigationBarIconic']) { $caption1 = '<<'; $caption2 = ' < '; $title1 = ' title="' . $GLOBALS['strPos1'] . '"'; $title2 = ' title="' . $GLOBALS['strPrevious'] . '"'; } else { $caption1 = $GLOBALS['strPos1'] . ' <<'; $caption2 = $GLOBALS['strPrevious'] . ' <'; $title1 = ''; $title2 = ''; } // end if... else... ?><td> <form action="sql.php" method="post"> <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" /> <input type="hidden" name="pos" value="0" /> <input type="hidden" name="goto" value="<?php echo $goto; ?>" /> <input type="submit" name="navig" value="<?php echo $caption1; ?>"<?php echo $title1; ?> /> </form></td><td> <form action="sql.php" method="post"> <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> <input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" /> <input type="hidden" name="pos" value="<?php echo $pos_prev; ?>" /> <input type="hidden" name="goto" value="<?php echo $goto; ?>" /> <input type="submit" name="navig" value="<?php echo $caption2; ?>"<?php echo $title2; ?> /> </form></td> <?php } // end move back
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?