From b9baa825c1999c4e33f31d88391f6e0b4597cb3b Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 21 May 2008 15:49:57 +0000 Subject: [PATCH] display options (work in progress) --- ChangeLog | 3 +- Documentation.html | 4 - libraries/common.lib.php | 30 ++++++- libraries/config.default.php | 7 -- libraries/display_tbl.lib.php | 154 ++++++++++++++++++++-------------- sql.php | 3 + tbl_change.php | 6 +- tbl_replace.php | 3 + 8 files changed, 130 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index f29e18fc5..5ab8f5056 100644 --- a/ChangeLog +++ b/ChangeLog @@ -45,7 +45,7 @@ danbarry + [lang] Norwegian update, thanks to Sven-Erik Andersen + [lang] Japanese update, thanks to Ishigaki Kenichi + [lang] Italian update, thanks to Luca Rebellato -+ [gui] Events (work in progress) ++ [gui] Events * minimal support on db structure page * export + [pdf] Merged tcpdf 2.2.002 (PHP5 version), thanks to Nicola Asuni @@ -54,6 +54,7 @@ danbarry + prevent search indexes from indexing phpMyAdmin installations + [engines] PBXT: table options, foreign key (relation view, designer) + [lang] New Bangla, thanks to Raquibul Islam and Joy Kumar Nag ++ [interface] Display options (work in progress) 2.11.7.0 (not yet released) - bug #1908719 [interface] New field cannot be auto-increment and primary key diff --git a/Documentation.html b/Documentation.html index 4e0476185..5a89f7f1c 100644 --- a/Documentation.html +++ b/Documentation.html @@ -1312,10 +1312,6 @@ ALTER TABLE `pma_column_comments`
Defines whether to suggest a database name on the "Create Database" form or to keep the textfield empty.
-
$cfg['ShowBlob'] boolean
-
Defines whether or not BLOB fields are shown when browsing a table's - content.
-
$cfg['NavigationBarIconic'] string
Defines whether navigation bar buttons and the right panel top menu contain text or symbols only. A value of TRUE displays icons, FALSE diff --git a/libraries/common.lib.php b/libraries/common.lib.php index bf56fda40..6771b51c6 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1236,7 +1236,7 @@ function PMA_profilingCheckbox($sql_query) echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); echo '' . "\n"; echo '' . "\n"; - echo '' . "\n"; + PMA_generate_html_checkbox('profiling', $GLOBALS['strProfiling'], isset($_SESSION['profiling']), true); echo '' . "\n"; echo '' . "\n"; } @@ -2285,6 +2285,18 @@ function PMA_externalBug($functionality, $component, $minimum_version, $bugref) } } +/** + * Generates and echoes an HTML checkbox + * + * @param string $html_field_name the checkbox HTML field + * @param string $label + * @param boolean $checked is it initially checked? + * @param boolean $onclick should it submit the form on click? + */ +function PMA_generate_html_checkbox($html_field_name, $label, $checked, $onclick) { + + echo ''; +} /** * Generates and echoes a set of radio HTML fields @@ -2495,4 +2507,20 @@ function PMA_foreignkey_supported($engine) { return false; } } + +/** + * Replaces some characters by a displayable equivalent + * + * @uses str_replace() + * @param string $content + * @return string the content with characters replaced + */ +function PMA_replace_binary_contents($content) { + $result = str_replace("\x00", '\0', $content); + $result = str_replace("\x08", '\b', $result); + $result = str_replace("\x0a", '\n', $result); + $result = str_replace("\x0d", '\r', $result); + $result = str_replace("\x1a", '\Z', $result); + return $result; +} ?> diff --git a/libraries/config.default.php b/libraries/config.default.php index 2b3b55bb9..9eb90e9bb 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -746,13 +746,6 @@ $cfg['SuggestDBName'] = true; * In browse mode... */ -/** - * display blob field contents - * - * @global boolean $cfg['ShowBlob'] - */ -$cfg['ShowBlob'] = false; - /** * Use icons instead of text for the navigation bar buttons * and on right panel top menu (server db table) (true|false|'both') diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 85daeb6c0..0c653afcf 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -426,7 +426,8 @@ onsubmit="return (checkFormElementInRange(this, 'session_max_rows', ''; + $url_params = array( + 'db' => $db, + 'table' => $table, + 'sql_query' => $sql_query, + 'goto' => $goto, + 'display_options_form' => 1 + ); + echo PMA_generate_common_hidden_inputs($url_params); + echo '
'; + PMA_generate_slider_effect('displayoptions',$GLOBALS['strOptions']); + echo '
'; + + $choices = array( + 'P' => $GLOBALS['strPartialText'], + 'F' => $GLOBALS['strFullText'] + ); + PMA_generate_html_radio('display_text', $choices, $_SESSION['userconf']['display_text']); + + PMA_generate_html_checkbox('display_binary', $GLOBALS['strShow'] . ' BINARY', ! empty($_SESSION['userconf']['display_binary']), false); + + PMA_generate_html_checkbox('display_blob', $GLOBALS['strShow'] . ' BLOB', ! empty($_SESSION['userconf']['display_blob']), false); + + echo ' '; + echo '
'; + echo ''; + + // Start of form for multi-rows edit/delete/export if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') { echo '
' . "\n"; @@ -564,29 +593,6 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ ? ' rowspan="3"' : ''; } - $url_params = array( - 'db' => $db, - 'table' => $table, - 'sql_query' => $sql_query, - 'goto' => $goto, - ); - $text_message = '' . $GLOBALS['strPartialText'] . ' - + - - + - > + > ' . "\n" - . ' ' . $text_link . "\n" + . ' ' . "\n" . ' ' . "\n"; } // end vertical mode } @@ -848,7 +853,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ } // end else (2.2) } // end for - // 3. Displays the full/partial text button (part 2) at the right + // 3. Displays the needed checkboxes at the right // column of the result table header if possible and required... if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') @@ -859,13 +864,12 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ echo "\n"; ?> > - ' . "\n" - . ' ' . $text_link . "\n" + . ' ' . "\n" . ' ' . "\n"; } // end vertical mode } @@ -907,7 +911,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ * @uses $_SESSION['userconf']['disp_direction'] * @uses $_SESSION['userconf']['repeat_cells'] * @uses $_SESSION['userconf']['max_rows'] - * @uses $_SESSION['userconf']['dontlimitchars'] + * @uses $_SESSION['userconf']['display_text'] + * @uses $_SESSION['userconf']['display_binary'] + * @uses $_SESSION['userconf']['display_blob'] * @param integer the link id associated to the query which results have * to be displayed * @param array which elements to display @@ -1277,11 +1283,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { // b l o b - } elseif ($GLOBALS['cfg']['ShowBlob'] == false && stristr($meta->type, 'BLOB')) { + } elseif (empty($_SESSION['userconf']['display_blob']) && stristr($meta->type, 'BLOB')) { // loic1 : PMA_mysql_fetch_fields returns BLOB in place of - // TEXT fields type, however TEXT fields must be displayed - // even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type - // of the fields. + // TEXT fields type so we have to ensure it's really a BLOB $field_flags = PMA_DBI_field_flags($dt_result, $i); if (stristr($field_flags, 'BINARY')) { $blobtext = PMA_handle_non_printable_contents('BLOB', (isset($row[$i]) ? $row[$i] : ''), $transform_function, $transform_options, $default_function, $meta); @@ -1292,7 +1296,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { $vertical_display['data'][$row_no][$i] = ' NULL' . "\n"; } elseif ($row[$i] != '') { // garvin: if a transform function for blob is set, none of these replacements will be made - if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ! $_SESSION['userconf']['dontlimitchars']) { + if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['userconf']['display_text'] == 'P') { $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } // loic1: displays all space characters, 4 space @@ -1313,7 +1317,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { // nijel: Cut all fields to $GLOBALS['cfg']['LimitChars'] // lem9: (unless it's a link-type transformation) - if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ! $_SESSION['userconf']['dontlimitchars'] && !strpos($transform_function, 'link') === true) { + if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['userconf']['display_text'] == 'P' && !strpos($transform_function, 'link') === true) { $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } @@ -1322,7 +1326,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) { $row[$i] = PMA_printable_bit_value($row[$i], $meta->length); } elseif (stristr($field_flags, 'BINARY') && $meta->type == 'string') { - $row[$i] = PMA_handle_non_printable_contents('BINARY', $row[$i], $transform_function, $transform_options, $default_function, $meta); + if (isset($_SESSION['userconf']['display_binary'])) { + // user asked to see the real contents of BINARY fields + $row[$i] = PMA_replace_binary_contents($row[$i]); + } else { + // we show the BINARY message and field's size + // (or maybe use a transformation) + $row[$i] = PMA_handle_non_printable_contents('BINARY', $row[$i], $transform_function, $transform_options, $default_function, $meta); + } } // loic1: displays all space characters, 4 space // characters for tabulations and / @@ -1627,8 +1638,12 @@ function PMA_displayVerticalTable() * @uses $GLOBALS['cfg']['MaxRows'] * @uses $_SESSION['userconf']['pos'] * @uses $_REQUEST['pos'] - * @uses $_SESSION['userconf']['dontlimitchars'] - * @uses $_REQUEST['dontlimitchars'] + * @uses $_SESSION['userconf']['display_text'] + * @uses $_REQUEST['display_text'] + * @uses $_SESSION['userconf']['display_binary'] + * @uses $_REQUEST['display_binary'] + * @uses $_SESSION['userconf']['display_blob'] + * @uses $_REQUEST['display_blob'] * @uses PMA_isValid() * @uses $GLOBALS['sql_query'] * @todo make maximum remembered queries configurable @@ -1670,11 +1685,27 @@ function PMA_displayTable_checkConfigParams() $_SESSION['userconf']['query'][$sql_key]['pos'] = 0; } - if (PMA_isValid($_REQUEST['dontlimitchars'], array('0', '1'))) { - $_SESSION['userconf']['query'][$sql_key]['dontlimitchars'] = (int) $_REQUEST['dontlimitchars']; - unset($_REQUEST['dontlimitchars']); - } elseif (empty($_SESSION['userconf']['query'][$sql_key]['dontlimitchars'])) { - $_SESSION['userconf']['query'][$sql_key]['dontlimitchars'] = 0; + if (PMA_isValid($_REQUEST['display_text'], array('P', 'F'))) { + $_SESSION['userconf']['query'][$sql_key]['display_text'] = $_REQUEST['display_text']; + unset($_REQUEST['display_text']); + } elseif (empty($_SESSION['userconf']['query'][$sql_key]['display_text'])) { + $_SESSION['userconf']['query'][$sql_key]['display_text'] = 'P'; + } + + if (isset($_REQUEST['display_binary'])) { + $_SESSION['userconf']['query'][$sql_key]['display_binary'] = true; + unset($_REQUEST['display_binary']); + } elseif (isset($_REQUEST['display_options_form'])) { + // we know that the checkbox was unchecked + unset($_SESSION['userconf']['query'][$sql_key]['display_binary']); + } + + if (isset($_REQUEST['display_blob'])) { + $_SESSION['userconf']['query'][$sql_key]['display_blob'] = true; + unset($_REQUEST['display_blob']); + } elseif (isset($_REQUEST['display_options_form'])) { + // we know that the checkbox was unchecked + unset($_SESSION['userconf']['query'][$sql_key]['display_blob']); } // move current query to the last position, to be removed last @@ -1691,18 +1722,20 @@ function PMA_displayTable_checkConfigParams() } // populate query configuration - $_SESSION['userconf']['dontlimitchars'] = $_SESSION['userconf']['query'][$sql_key]['dontlimitchars']; + $_SESSION['userconf']['display_text'] = $_SESSION['userconf']['query'][$sql_key]['display_text']; + $_SESSION['userconf']['display_binary'] = isset($_SESSION['userconf']['query'][$sql_key]['display_binary']) ? true : false; + $_SESSION['userconf']['display_blob'] = isset($_SESSION['userconf']['query'][$sql_key]['display_blob']) ? true : false; $_SESSION['userconf']['pos'] = $_SESSION['userconf']['query'][$sql_key]['pos']; $_SESSION['userconf']['max_rows'] = $_SESSION['userconf']['query'][$sql_key]['max_rows']; $_SESSION['userconf']['repeat_cells'] = $_SESSION['userconf']['query'][$sql_key]['repeat_cells']; $_SESSION['userconf']['disp_direction'] = $_SESSION['userconf']['query'][$sql_key]['disp_direction']; /* - * debugging + * debugging echo '
';
     var_dump($_SESSION['userconf']);
     echo '
'; - */ + */ } /** @@ -1746,7 +1779,8 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) global $cfgRelation; global $showtable; - PMA_displayTable_checkConfigParams(); + // why was this called here? (already called from sql.php) + //PMA_displayTable_checkConfigParams(); /** * @todo move this to a central place @@ -1996,7 +2030,7 @@ function default_function($buffer) { * @param array the analyzed query * * @uses $_SESSION['userconf']['pos'] - * @uses $_SESSION['userconf']['dontlimitchars'] + * @uses $_SESSION['userconf']['display_text'] * @global string $db the database name * @global string $table the table name * @global string $sql_query the current SQL query @@ -2038,13 +2072,13 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) { PMA_getIcon('b_print.png', $GLOBALS['strPrintView'], false, true), '', true, true, 'print_view') . "\n"; - if (! $_SESSION['userconf']['dontlimitchars']) { - $_url_params['dontlimitchars'] = 1; + if ($_SESSION['userconf']['display_text']) { + $_url_params['display_text'] = 'F'; echo PMA_linkOrButton( 'sql.php' . PMA_generate_common_url($_url_params), PMA_getIcon('b_print.png', $GLOBALS['strPrintViewFull'], false, true), '', true, true, 'print_view') . "\n"; - unset($_url_params['dontlimitchars']); + unset($_url_params['display_text']); } } // end displays "printable view" } @@ -2132,13 +2166,9 @@ function PMA_handle_non_printable_contents($category, $content, $transform_funct $result = $transform_function($result, $transform_options, $meta); } else { $result = $default_function($result, array(), $meta); - if (stristr($meta->type, 'BLOB') && $GLOBALS['cfg']['ShowBlob'] == true) { + if (stristr($meta->type, 'BLOB') && isset($_SESSION['userconf']['display_blob'])) { // in this case, restart from the original $content - $result = str_replace("\x00", '\0', $content); - $result = str_replace("\x08", '\b', $result); - $result = str_replace("\x0a", '\n', $result); - $result = str_replace("\x0d", '\r', $result); - $result = str_replace("\x1a", '\Z', $result); + $result = PMA_replace_binary_contents($content); } } } diff --git a/sql.php b/sql.php index 9be597cdf..281dc6c5c 100644 --- a/sql.php +++ b/sql.php @@ -14,6 +14,9 @@ require_once './libraries/Table.class.php'; require_once './libraries/check_user_privileges.lib.php'; require_once './libraries/bookmark.lib.php'; +$GLOBALS['js_include'][] = 'mootools.js'; +$GLOBALS['js_include'][] = 'mootools-domready.js'; + /** * Defines the url to return to in case of error in a sql statement */ diff --git a/tbl_change.php b/tbl_change.php index 4980a9246..77677c3a1 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -425,11 +425,7 @@ foreach ($rows as $row_id => $vrow) { } else { // loic1: special binary "characters" if ($field['is_binary'] || $field['is_blob']) { - $vrow[$field['Field']] = str_replace("\x00", '\0', $vrow[$field['Field']]); - $vrow[$field['Field']] = str_replace("\x08", '\b', $vrow[$field['Field']]); - $vrow[$field['Field']] = str_replace("\x0a", '\n', $vrow[$field['Field']]); - $vrow[$field['Field']] = str_replace("\x0d", '\r', $vrow[$field['Field']]); - $vrow[$field['Field']] = str_replace("\x1a", '\Z', $vrow[$field['Field']]); + $vrow[$field['Field']] = PMA_replace_binary_contents($vrow[$field['Field']]); } // end if $special_chars = htmlspecialchars($vrow[$field['Field']]); $data = $vrow[$field['Field']]; diff --git a/tbl_replace.php b/tbl_replace.php index 9ca895c1e..ea66322fd 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -361,6 +361,9 @@ if (isset($return_to_sql_query)) { $GLOBALS['js_include'][] = 'tbl_change.js'; $GLOBALS['js_include'][] = 'functions.js'; +// in case we call sql.php which needs those: +$GLOBALS['js_include'][] = 'mootools.js'; +$GLOBALS['js_include'][] = 'mootools-domready.js'; $active_page = $goto_include; require_once './libraries/header.inc.php';