From b8741540db58ef0638fa7d96240f583b364a24d2 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Tue, 27 Sep 2005 13:53:49 +0000 Subject: [PATCH] moved all code for queryboxes into libraries/sql_query_form.lib.php, replaced table with fieldsets, moved styles into css, minor interface changes related to queryboxes --- ChangeLog | 7 + css/phpmyadmin.css.php | 78 ++++- db_details.php | 246 +------------- libraries/sql_query_form.lib.php | 515 ++++++++++++++++++++++++++++ querywindow.php | 63 +++- read_dump.php | 4 +- server_sql.php | 200 +---------- sql.php | 5 +- tbl_properties.php | 20 +- tbl_properties_structure.php | 4 +- tbl_query_box.php | 564 ++----------------------------- 11 files changed, 711 insertions(+), 995 deletions(-) create mode 100644 libraries/sql_query_form.lib.php diff --git a/ChangeLog b/ChangeLog index 0e16e4261..4b9a7ee1f 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,13 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-09-26 Sebastian Mendel + * libraries/sql_query_form.lib.php, db_details.php, server_sql.php + tbl_properties.php, tbl_properties_structure.php, sql.php, + querywindow.php, read_dump.php: moved all code for queryboxes into + libraries/sql_query_form.lib.php, replaced table with fieldsets, moved + styles into css, minor interface changes related to queryboxes + 2005-09-27 Michal Čihař * lang/czech: Update. * server_status.php, lang/*: Separate some new information on MySQL 5. diff --git a/css/phpmyadmin.css.php b/css/phpmyadmin.css.php index 990c16f1e..8775dbbc7 100644 --- a/css/phpmyadmin.css.php +++ b/css/phpmyadmin.css.php @@ -89,10 +89,80 @@ body#bodyquerywindow { div#querywindowcontainer { margin: 0; - padding: 0.5em; - float: left; + padding: 0; + width: 100%; } +div#querywindowcontainer fieldset { + margin-top: 0; +} + + +/* querybox */ + +/* Gecko bug */ +div[id=queryfieldscontainer] { + border: 1px solid transparent; +} + + +div#sqlquerycontainer { + float: left; + width: 69%; + /* height: 15em; */ +} + +div#tablefieldscontainer { + float: right; + width: 29%; + /* height: 15em; */ +} + +div#tablefieldscontainer select { + width: 100%; + /* height: 12em; */ +} + +textarea#sqlquery { + width: 100%; + /* height: 100%; */ +} + +div#queryboxcontainer div#bookmarkoptions { + margin-top: 0.5em; +} + +fieldset .formelement { + line-height: 2.3em; + float: left; + margin-right: 0.5em; + /* IE */ + white-space: nowrap; +} +/* revert for Gecko */ +fieldset div[class=formelement] { + white-space: normal; +} + +/* IE */ +fieldset .formelement input, +fieldset .formelement select { + margin-top: 0.5em; + margin-bottom: 0.5em; + height: 1.3em; +} +/* revert for Gecko */ +fieldset div[class=formelement] input, +fieldset div[class=formelement] select { + margin-top: auto; + margin-bottom: auto; + height: auto; +} + + +/* end querybox */ + + /* Calendar */ table.calendar { width: 100%; } table.calendar td { text-align: center; } @@ -115,10 +185,10 @@ form.clock { text-align: center; } /* end Calendar */ /* Options, eg. on import page */ -fieldset.options { +fieldset { background-color: ; } -fieldset.options legend { +fieldset legend { background-color: transparent; } diff --git a/db_details.php b/db_details.php index 1d5e3dd50..dc4c9ffb1 100644 --- a/db_details.php +++ b/db_details.php @@ -7,253 +7,27 @@ * Runs common work */ require('./db_details_common.php'); -$url_query .= '&goto=db_details.php'; - - -/** - * Database work - */ -if (isset($show_query) && $show_query == '1') { - // This script has been called by read_dump.php - if (isset($sql_query_cpy)) { - $query_to_display = $sql_query_cpy; - } - // Other cases - else { - $query_to_display = $sql_query; - } -} else { - $query_to_display = ''; -} - +require_once './libraries/sql_query_form.lib.php'; /** * Gets informations about the database and, if it is empty, move to the * "db_details_structure.php" script where table can be created */ -$sub_part = ''; require('./db_details_db_info.php'); -if ($num_tables == 0 && empty($db_query_force)) { - $is_info = TRUE; - require('./db_details_structure.php'); +if ( $num_tables == 0 && empty( $db_query_force ) ) { + $sub_part = ''; + $is_info = TRUE; + require './db_details_structure.php'; exit(); } -// loic1: defines wether file upload is available or not -// (now defined in common.lib.php) +/** + * Query box, bookmark, insert data from textfile + */ +PMA_sqlQueryForm(); -$auto_sel = ($cfg['TextareaAutoSelect'] - // 2003-02-05 rabus: This causes big trouble with Opera 7 for - // Windows, so let's disable it there... - && !(PMA_USR_OS == 'Win' && PMA_USR_BROWSER_AGENT == 'OPERA' && PMA_USR_BROWSER_VER >= 7)) - ? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"' - : ''; - - -// for better administration -$strHiddenFields = ' ' ."\n" - . ' ' .PMA_generate_common_hidden_inputs($db) . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; -?> - -
onsubmit="return checkSqlQuery(this)" name="sqlform"> - - - - - - - - - - - - - - - - ' . "\n" - . '' . "\n" - . '' . "\n" - . ' - - ' . "\n"; - echo ' ' - . ' ' . "\n\n"; - } // end if (isfirst > 0) - @closedir($handle); - } - else { - $upload_dir_error = '' . "\n" - . '' . "\n" - . '' . "\n"; - } -} // end if (web-server upload directory) -// Charset conversion options -if ($is_upload || $is_upload_dir) { - echo ' ' . "\n"; - echo ' ' . "\n"; - echo ' ' . "\n"; -} -// Bookmark Support -if ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table']) { - if (($bookmark_list = PMA_listBookmarks($db, $cfg['Bookmark'])) && count($bookmark_list) > 0) { - echo ' ' . "\n"; - echo ' ' . "\n"; - echo ' ' . "\n"; - echo ' '; - echo ' ' . "\n"; - } -} - -// Encoding setting form appended by Y.Kawada -if (function_exists('PMA_set_enc_form')) { - echo PMA_set_enc_form(' '); -} -// modified by mkkeck 2004-05-08 -// showing UploadDir Error at the end of all option for SQL-Queries -if (isset($upload_dir_error)) { - echo $upload_dir_error; -} -?> -
- ' - . htmlspecialchars($db) . ''; - // else use - // $strDBLink = htmlspecialchars($db); - echo ' ' . sprintf($strRunSQLQuery, $strDBLink) . ': ' . PMA_showMySQLDocu('Reference', 'SELECT'); - - ?> -
- -
- -
- - : -
-   - '; - // some browsers should respect this :) - echo ' ' . PMA_generateHiddenMaxFileSize($max_upload_size) . "\n"; - $is_gzip = ($cfg['GZipDump'] && @function_exists('gzopen')); - $is_bzip = ($cfg['BZipDump'] && @function_exists('bzdecompress')); - if ($is_bzip || $is_gzip) { - echo '
' . "\n"; - echo '   ' . $strCompression . ':
   ' . "\n" - . '   ' . "\n" - . '   ' . "\n"; - if ($is_gzip) { - echo '   ' . "\n"; - } - if ($is_bzip) { - echo '   ' . "\n"; - } - } else { - ?> - -
' . "\n"; - echo '  ' . $strWebServerUploadDirectory . ': ' . "\n"; - echo '
' . "\n"; - // add 2004-05-08 by mkkeck - // todo: building a php script for indexing files in UploadDir - //if ($cfg['UploadDirIndex']) { - // echo ' ' . $cfg['UploadDir'] . ' '; - //} - // end indexing - echo ' ' . "\n" - . '
' . $strError . '
' . $strWebServerUploadDirectoryError - . '
' . "\n"; - if (PMA_MYSQL_INT_VERSION < 40100 && $cfg['AllowAnywhereRecoding'] && $allow_recoding) { - $temp_charset = reset($cfg['AvailableCharsets']); - echo ' ' . $strCharsetOfFile . "\n" - . '
' . "\n" . ' '; - } elseif (PMA_MYSQL_INT_VERSION >= 40100) { - echo $strCharsetOfFile . "\n"; - echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', NULL, 'utf8', FALSE); - } // end if (recoding) - echo '
 ' . $strOr . '
' . "\n"; - echo ' ' . $strBookmarkQuery . ': ' . "\n"; - echo ' ' . "\n"; - echo '
'; - echo ' ' . $strVar . ' '; - if ($cfg['ReplaceHelpImg']){ - echo '' - . '' . $strDocu . ''; - }else{ - echo '(' . $strDocu . '): '; - } - echo ' ' . "\n"; - echo '
'; - echo ' ' . "\n"; - echo '  ' . "\n"; - echo '  ' . "\n"; - echo '
-
- diff --git a/libraries/sql_query_form.lib.php b/libraries/sql_query_form.lib.php new file mode 100644 index 000000000..9bad54d24 --- /dev/null +++ b/libraries/sql_query_form.lib.php @@ -0,0 +1,515 @@ + +
name="sqlform" + onsubmit="this.target=window.opener.parent.frames[2].name; + return checkSqlQuery(this);" > + ' . "\n"; + } + + if ( $is_querywindow ) { + echo '' + ."\n"; + if ( $display_tab != 'sql' && $display_tab != 'full' ) { + echo '' . "\n"; + echo '' . "\n"; + } + } + echo '' . "\n" + .PMA_generate_common_hidden_inputs( $db, $table ) . "\n" + .'' . "\n" + .'' . "\n" + .'' . "\n" + .'' . "\n"; + + // display querybox + if ( $display_tab === 'full' || $display_tab === 'sql' ) { + PMA_sqlQueryFormInsert( $query, $is_querywindow ); + } + + // display uploads + if ( $display_tab === 'full' || $display_tab === 'files' ) { + if ( $GLOBALS['is_upload'] ) { + PMA_sqlQueryFormUpload( $display_tab ); + } + } + + // Bookmark Support + if ( $display_tab === 'full' || $display_tab === 'history' ) { + if ( ! empty( $GLOBALS['cfg']['Bookmark'] ) + && $GLOBALS['cfg']['Bookmark']['db'] + && $GLOBALS['cfg']['Bookmark']['table'] ) { + PMA_sqlQueryFormBookmark( $display_tab ); + } + } + + // Encoding setting form appended by Y.Kawada + if ( function_exists('PMA_set_enc_form') ) { + echo PMA_set_enc_form(' '); + } + + echo '
' . "\n"; +} + +/** + * + * @param string $query query to display in the textarea + * @uses $GLOBALS['text_dir'] + * @uses $GLOBALS['cfg']['QueryFrameJS'] + * @uses $GLOBALS['cfg']['TextareaAutoSelect'] + * @uses $GLOBALS['cfg']['TextareaCols'] + * @uses $GLOBALS['cfg']['TextareaRows'] + * @uses $GLOBALS['strShowThisQuery'] + * @uses $GLOBALS['strGo'] + * @uses PMA_availableDatabases() + * @uses PMA_USR_OS + * @uses PMA_USR_BROWSER_AGENT + * @uses PMA_USR_BROWSER_VER + * @uses PMA_availableDatabases() + * @uses htmlspecialchars() + */ +function PMA_sqlQueryFormInsert( $query = '', $is_querywindow = false ) { + + // enable auto select text in textarea + if ( $GLOBALS['cfg']['TextareaAutoSelect'] ) { + $auto_sel = ' onfocus="if (typeof(document.layers) == \'undefined\' || ' + .' typeof(textarea_selected) == \'undefined\') {textarea_selected ' + .'= 1; this.form.elements[\'sql_query\'].select();}"'; + } else { + $auto_sel = ''; + } + + // enable locking if inside query window + if ( $GLOBALS['cfg']['QueryFrameJS'] && $is_querywindow ) { + $locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].' + .'checked = true;"'; + } else { + $locking = ''; + } + + $table = ''; + $db = ''; + $fields_list = array(); + if ( empty( $GLOBALS['db'] ) ) { + // prepare for server related + $legend = sprintf( $GLOBALS['strRunSQLQueryOnServer'], + htmlspecialchars( + $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host'] ) ); + } + elseif ( empty( $GLOBALS['table'] ) ) { + // prepare for db related + $db = $GLOBALS['db']; + // if you want navigation: + $strDBLink = '' + . htmlspecialchars( $db ) . ''; + // else use + // $strDBLink = htmlspecialchars( $db ); + $legend = sprintf( $GLOBALS['strRunSQLQuery'], $strDBLink ); + if ( empty( $query ) ) { + $query = str_replace( '%d', + PMA_backquote( $db ), $GLOBALS['cfg']['DefaultQueryDatabase'] ); + } + } else { + $table = $GLOBALS['table']; + $db = $GLOBALS['db']; + // Get the list and number of fields + // we do a try_query here, because we could be in the query window, + // trying to synchonize and the table has not yet been created + $fields_list = PMA_DBI_fetch_result( + 'SHOW FULL COLUMNS FROM ' . PMA_backquote( $db ) + . '.' . PMA_backquote( $GLOBALS['table'] )); + + $strDBLink = '' + . htmlspecialchars( $db ) . ''; + // else use + // $strDBLink = htmlspecialchars( $db ); + $legend = sprintf( $GLOBALS['strRunSQLQuery'], $strDBLink ); + if ( empty( $query ) && count( $fields_list ) ) { + $query = + str_replace( '%d', PMA_backquote( $db ), + str_replace( '%t', PMA_backquote( $table ), + str_replace( '%f', + implode( ', ', PMA_backquote( $fields_list ) ), + $GLOBALS['cfg']['DefaultQueryTable'] ) ) ); + } + } + $legend .= ': ' . PMA_showMySQLDocu( 'Reference', 'SELECT' ); + + if ( count( $fields_list ) ) { + $sqlquerycontainer_id = 'sqlquerycontainer'; + } else { + $sqlquerycontainer_id = 'sqlquerycontainerfull'; + } + + echo '' . "\n" + .'
' . "\n" + .'
' . "\n"; + echo '' . $legend . '' . "\n"; + echo '
' . "\n"; + echo '
' . "\n" + .'' . "\n"; + echo '
' . "\n"; + + if ( count( $fields_list ) ) { + echo '
' . "\n" + .'' . "\n" + .'' . "\n" + .'
' . "\n"; + if ( $GLOBALS['cfg']['PropertiesIconic'] ) { + echo '' . "\n"; + } else { + echo '' . "\n"; + } + echo '
' . "\n" + .'
' . "\n"; + } + + echo '
' . "\n"; + echo '
' . "\n"; + + if ( ! empty( $GLOBALS['cfg']['Bookmark'] ) + && $GLOBALS['cfg']['Bookmark']['db'] + && $GLOBALS['cfg']['Bookmark']['table'] ) { + ?> +
+
+ + +
+
+ + +
+
+
' . "\n"; + echo '' . "\n" + .'' . "\n"; + + echo '
' . "\n"; + echo '
' . "\n"; + if ( $is_querywindow ) { + ?> + + ' . "\n"; + echo '
' . "\n"; + echo '' . "\n" + .'' . "\n"; + echo '
' . "\n"; + echo '' + ."\n"; + echo '
' . "\n"; + echo '
' . "\n"; +} + +function PMA_sqlQueryFormBookmark( $display_tab = 'full' ) { + $bookmark_list = PMA_listBookmarks( + $GLOBALS['db'], $GLOBALS['cfg']['Bookmark'] ); + if ( count( $bookmark_list ) < 1 ) { + return; + } + + echo '
'; + echo ''; + if ( $display_tab == 'full' ) { + echo '' . $GLOBALS['strOr'] . ' '; + } + echo $GLOBALS['strBookmarkQuery'] . '' . "\n"; + echo '
'; + echo ' ' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo $GLOBALS['strVar']; + if ( $GLOBALS['cfg']['ReplaceHelpImg'] ) { + echo ' ' + .'' . $GLOBALS['strDocu'] . ' '; + } else { + echo ' (' . $GLOBALS['strDocu'] . '): '; + } + echo '' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '' + .'' . "\n"; + echo '' + .'' . "\n"; + echo '' + .'' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + echo '
' . "\n"; + + echo '
' . "\n"; + echo ''; + echo '
' . "\n"; + echo '
' . "\n"; +} + +function PMA_sqlQueryFormUpload( $display_tab = 'full' ) { + $uploaded_files = array(); + $errors = array(); + $is_gzip = ($GLOBALS['cfg']['GZipDump'] && @function_exists('gzopen')); + $is_bzip = ($GLOBALS['cfg']['BZipDump'] && @function_exists('bzdecompress')); + + if ( ! empty( $GLOBALS['cfg']['UploadDir'] ) ) { + if ( substr($GLOBALS['cfg']['UploadDir'], -1) != '/' ) { + $GLOBALS['cfg']['UploadDir'] .= '/'; + } + if ( $handle = @opendir( $GLOBALS['cfg']['UploadDir'] ) ) { + while ( $file = @readdir( $handle ) ) { + if ( is_file( $GLOBALS['cfg']['UploadDir'] . $file ) + && PMA_checkFileExtensions( $file, '.sql' ) ) + { + $uploaded_files[] = $file; + } + } // end while + @closedir( $handle ); + } + else { + $errors[$GLOBALS['strError']] = + $GLOBALS['strWebServerUploadDirectoryError']; + } + } // end if (web-server upload directory) + + // start output + echo '
'; + echo ''; + if ( $display_tab == 'full' ) { + echo '' . $GLOBALS['strOr'] . ' '; + } + echo $GLOBALS['strLocationTextfile'] . ''; + echo '
'; + echo ' '; + echo PMA_displayMaximumUploadSize( $GLOBALS['max_upload_size'] ); + // some browsers should respect this :) + echo PMA_generateHiddenMaxFileSize( $GLOBALS['max_upload_size'] ) . "\n"; + echo '
'; + + if ( $is_bzip || $is_gzip ) { + echo '
'; + echo $GLOBALS['strCompression'] . ': ' . "\n" + .'' + .'' . "\n" + .'' + .'' . "\n"; + if ( $is_gzip ) { + echo '' + .'' . "\n"; + } + if ( $is_bzip ) { + echo '' + .'' . "\n"; + } + echo '
'; + } else { + echo ''; + } + + if ( count( $uploaded_files ) > 0 ) { + echo '' . $GLOBALS['strWebServerUploadDirectory'] + .':' . "\n"; + echo '' . "\n"; + } + echo '
' . "\n"; + echo '
'; + + + echo '
'; + if ( PMA_MYSQL_INT_VERSION < 40100 + && $GLOBALS['cfg']['AllowAnywhereRecoding'] + && $GLOBALS['allow_recoding'] ) { + echo $GLOBALS['strCharsetOfFile'] . "\n" + . '' . "\n"; + } elseif ( PMA_MYSQL_INT_VERSION >= 40100 ) { + echo $GLOBALS['strCharsetOfFile'] . "\n"; + echo PMA_generateCharsetDropdownBox( PMA_CSDROPDOWN_CHARSET, + 'charset_of_file', NULL, 'utf8', FALSE ); + } // end if (recoding) + echo '' . "\n"; + echo '
' . "\n"; + echo '
'; + + foreach( $errors as $error => $message ) { + echo '
' . $error . '
'; + echo '
' . $message . '
'; + } +} +?> + diff --git a/querywindow.php b/querywindow.php index 3e51a7185..7ff371eec 100644 --- a/querywindow.php +++ b/querywindow.php @@ -17,6 +17,7 @@ if (!empty($db)) { * Gets a core script and starts output buffering work */ require_once('./libraries/common.lib.php'); +require_once './libraries/sql_query_form.lib.php'; require_once('./libraries/ob.lib.php'); if ($cfg['OBGzip']) { $ob_mode = PMA_outBufferModeGet(); @@ -68,24 +69,29 @@ var confirmMsg = ' - function resize() { - if( typeof( self.sizeToContent ) == 'function' ) { + + // for Gecko + if ( typeof( self.sizeToContent ) == 'function' ) { self.sizeToContent(); - self.scrollbars.visible = false; + //self.scrollbars.visible = false; + // give some more space ... to prevent 'fli(pp/ck)ing' + self.resizeBy( 10, 50 ); return; } + // for IE, Opera if (document.getElementById && typeof(document.getElementById('querywindowcontainer')) != 'undefined' ) { // get content size var newWidth = document.getElementById('querywindowcontainer').offsetWidth; var newHeight = document.getElementById('querywindowcontainer').offsetHeight; - // set size to contentsize + offsetsize - self.resizeTo( newWidth + 50, newHeight + 150 ); + // set size to contentsize + // plus some offset for scrollbars, borders, statusbar, menus ... + self.resizeTo( newWidth + 45, newHeight + 75 ); } } ">
-
- $db, diff --git a/server_sql.php b/server_sql.php index bc0762f20..7b7ab6083 100644 --- a/server_sql.php +++ b/server_sql.php @@ -6,211 +6,23 @@ /** * Does the common work */ -require('./server_common.inc.php'); +require_once './server_common.inc.php'; +require_once './libraries/sql_query_form.lib.php'; /** * Displays the links */ -require('./server_links.inc.php'); - +require './server_links.inc.php'; /** - * Database work + * Query box, bookmark, insert data from textfile */ -if (isset($show_query) && $show_query == '1') { - // This script has been called by read_dump.php - if (isset($sql_query_cpy)) { - $query_to_display = $sql_query_cpy; - } - // Other cases - else { - $query_to_display = $sql_query; - } -} else { - $query_to_display = ''; -} +PMA_sqlQueryForm(); - -// loic1: defines wether file upload is available or not -// (now defined in common.lib.php) - -$auto_sel = ($cfg['TextareaAutoSelect'] - // 2003-02-05 rabus: This causes big trouble with Opera 7 for - // Windows, so let's disable it there... - && !(PMA_USR_OS == 'Win' && PMA_USR_BROWSER_AGENT == 'OPERA' && PMA_USR_BROWSER_VER >= 7)) - ? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; this.form.elements[\'sql_query\'].select();}"' - : ''; - - -// for better administration -$strHiddenFields = ' ' ."\n" - . ' ' .PMA_generate_common_hidden_inputs() . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n"; -?> - -
onsubmit="return checkSqlQuery(this)" name="sqlform"> - - - - - - - - - - - - - - - - ' . "\n" - . '' . "\n" - . '' . "\n" - . ' - - ' . "\n"; - echo ' ' - . ' ' . "\n\n"; - } // end if (isfirst > 0) - @closedir($handle); - } - else { - $upload_dir_error = '' . "\n" - . '' . "\n" - . '' . "\n"; - } -} // end if (web-server upload directory) -// Charset conversion options -if ($is_upload || $is_upload_dir) { - echo ' ' . "\n"; - echo ' ' . "\n"; - echo ' ' . "\n"; -} - - -// Encoding setting form appended by Y.Kawada -if (function_exists('PMA_set_enc_form')) { - echo PMA_set_enc_form(' '); -} -// modified by mkkeck 2004-05-08 -// showing UploadDir Error at the end of all option for SQL-Queries -if (isset($upload_dir_error)) { - echo $upload_dir_error; -} -?> -
- -
- -
- -
- - : -
-   - '; - // some browsers should respect this :) - echo ' ' . PMA_generateHiddenMaxFileSize($max_upload_size) . "\n"; - $is_gzip = ($cfg['GZipDump'] && @function_exists('gzopen')); - $is_bzip = ($cfg['BZipDump'] && @function_exists('bzdecompress')); - if ($is_bzip || $is_gzip) { - echo '
' . "\n"; - echo '   ' . $strCompression . ':
   ' . "\n" - . '   ' . "\n" - . '   ' . "\n"; - if ($is_gzip) { - echo '   ' . "\n"; - } - if ($is_bzip) { - echo '   ' . "\n"; - } - } else { - ?> - -
' . "\n"; - echo '  ' . $strWebServerUploadDirectory . ': ' . "\n"; - echo '
' . "\n"; - // add 2004-05-08 by mkkeck - // todo: building a php script for indexing files in UploadDir - //if ($cfg['UploadDirIndex']) { - // echo ' ' . $cfg['UploadDir'] . ' '; - //} - // end indexing - echo ' ' . "\n" - . '
' . $strError . '
' . $strWebServerUploadDirectoryError - . '
' . "\n"; - if (PMA_MYSQL_INT_VERSION < 40100 && $cfg['AllowAnywhereRecoding'] && $allow_recoding) { - $temp_charset = reset($cfg['AvailableCharsets']); - echo ' ' . $strCharsetOfFile . "\n" - . '
' . "\n" . ' '; - } elseif (PMA_MYSQL_INT_VERSION >= 40100) { - echo $strCharsetOfFile . "\n"; - echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', NULL, 'utf8', FALSE); - } // end if (recoding) - echo '
-
- diff --git a/sql.php b/sql.php index 6bd94cf85..f4e46bdbb 100644 --- a/sql.php +++ b/sql.php @@ -103,6 +103,7 @@ if (isset($btnDrop) || isset($navig)) { $GLOBALS['unparsed_sql'] = $sql_query; $parsed_sql = PMA_SQP_parse($sql_query); $analyzed_sql = PMA_SQP_analyze($parsed_sql); + // Bug #641765 - Robbat2 - 12 January 2003, 10:49PM // Reverted - Robbat2 - 13 January 2003, 2:40PM @@ -627,8 +628,8 @@ else { $message = $strAffectedRows . ' ' . $num_rows; // Ok, here is an explanation for the !$is_select. - // The form generated - // by tbl_query_box.php and db_details.php has many submit buttons + // The form generated by sql_query_form.lib.php + // and db_details.php has many submit buttons // on the same form, and some confusion arises from the // fact that $zero_rows is sent for every case. // The $zero_rows containing $strSuccess and sent with diff --git a/tbl_properties.php b/tbl_properties.php index dd95fa5a0..ef11dbccb 100644 --- a/tbl_properties.php +++ b/tbl_properties.php @@ -6,32 +6,30 @@ /** * Runs common work */ -require('./tbl_properties_common.php'); +require './tbl_properties_common.php'; +require_once './libraries/sql_query_form.lib.php'; + $err_url = 'tbl_properties.php' . $err_url; -$url_query .= '&goto=tbl_properties.php&back=tbl_properties.php'; +$goto = 'tbl_properties.php'; +$back = 'tbl_properties.php'; /** * Get table information */ -require('./tbl_properties_table_info.php'); +require './tbl_properties_table_info.php'; /** * Displays top menu links */ -require('./tbl_properties_links.php'); +require './tbl_properties_links.php'; -?> - - diff --git a/tbl_properties_structure.php b/tbl_properties_structure.php index 157573ad8..10e8c979c 100644 --- a/tbl_properties_structure.php +++ b/tbl_properties_structure.php @@ -5,6 +5,7 @@ require_once('./libraries/grab_globals.lib.php'); require_once('./libraries/common.lib.php'); require_once('./libraries/mysql_charsets.lib.php'); +require_once './libraries/sql_query_form.lib.php'; /** * Drop multiple fields if required @@ -807,7 +808,8 @@ if (!$tbl_is_view) { * Query box, bookmark, insert data from textfile */ $goto = 'tbl_properties_structure.php'; -require('./tbl_query_box.php'); +PMA_sqlQueryForm(); + /** * Displays the footer diff --git a/tbl_query_box.php b/tbl_query_box.php index cf6a16c5f..4e3b83a25 100644 --- a/tbl_query_box.php +++ b/tbl_query_box.php @@ -1,547 +1,55 @@ = 7)) - ? "\n" . ' onfocus="if (typeof(document.layers) == \'undefined\' || typeof(textarea_selected) == \'undefined\') {textarea_selected = 1; document.sqlform.elements[\'sql_query\'].select();}"' - : ''; -$auto_sel .= ' ' . $locking; - -// garvin: If non-JS query window is embedded, display a list of databases to choose from. -// Apart from that, a non-js query window sucks badly. -/** - * Get the list and number of available databases. - */ -if ($server > 0) { - PMA_availableDatabases(); // this function is defined in "common.lib.php" -} else { - $num_dbs = 0; -} -if ($cfg['QueryFrame'] && (!$cfg['QueryFrameJS'] && !$db || ($cfg['QueryFrameJS'] && !$db))) { - if ($num_dbs > 0) { - $queryframe_db_list = ' '; - $queryframe_thcolspan = ' colspan="2"'; - $queryframe_tdcolspan = ''; - } else { - $queryframe_db_list = ''; - $queryframe_thcolspan = ' colspan="3"'; - $queryframe_tdcolspan = ' colspan="2"'; - } -} else { - $queryframe_db_list = ''; - if ($num_dbs > 0) { - $queryframe_thcolspan = ' colspan="3"'; - $queryframe_tdcolspan = ' colspan="2"'; - } else { - $queryframe_thcolspan = ' colspan="2"'; - $queryframe_tdcolspan = ''; - } -} -$form_items = 0; -// ($is_upload defined in common.lib.php) - -if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && isset($is_inside_querywindow) && $is_inside_querywindow) { -?> - -' . "\n" - . '
' . "\n" - . ' '; -} else { -?> - onsubmit="return checkSqlQuery(this)" name="sqlform" style="padding: 0px; magin: 0px;"> - - -' . "\n" - . ' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n" - . ' '. "\n" - . ' '. "\n" - . ' '. "\n" - . ' '. "\n"; -if (!isset($is_inside_querywindow) || - (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full'))) { -?> - -' . "\n"; - } -?> - - - 0) { ?> - - - - - - - 0) { -?> - - - - - - > - - -
- - - -
- -' . "\n"; - $querybox_hidden_fields .= ' ' . "\n"; -} - -// loic1: displays import dump feature only if file upload available -if ($is_upload && (!isset($is_inside_querywindow) || - (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' || $querydisplay_tab == 'full')))) { - $form_items++; -?> - - > - - - - - - > -    
-' . "\n"; - } - - $is_gzip = ($cfg['GZipDump'] && @function_exists('gzopen')); - $is_bzip = ($cfg['BZipDump'] && @function_exists('bzdecompress')); - if ($is_bzip || $is_gzip) { - echo ' ' . "\n" - . '
' . "\n" - . ' ' . "\n" - . ' ' . "\n" - . '   '. $strCompression . ':
  ' . "\n" - . '   ' - . '  ' . "\n" - . ' ' - . '  ' . "\n"; - if ($is_gzip) { - echo ' ' - . '  ' . "\n"; - } - if ($is_bzip) { - echo ' ' - . '  ' . "\n"; - } - } else { - $querybox_hidden_fields .= ' ' . "\n"; - } - ?> - -
- ' . "\n"; - } - - $is_first = 0; - while ($file = @readdir($handle)) { - if (is_file($cfg['UploadDir'] . $file) && PMA_checkFileExtensions($file, '.sql')) { - if ($is_first == 0) { - $is_upload_dir = true; - echo "\n"; - echo ' ' . "\n" - . ' '; - echo '  ' . $strWebServerUploadDirectory . ': ' . "\n"; - echo ' ' . "\n" - . ' '; - // add 2004-05-08 by mkkeck - // todo: building a php script for indexing files in UploadDir - //if ($cfg['UploadDirIndex']) { - // echo '  ' . $cfg['UploadDir'] . ' '; - //} - // end indexing - echo '   ' . "\n" - . ' ' . "\n"; - } // end if (isfirst > 0) - @closedir($handle); - $upload_dir_error=''; // please see 'else {' below ;) - } - else { - // modified by mkkeck 2004-05-08 - // showing UploadDir Error at the end of all option for SQL-Queries - $upload_dir_error.= ' ' . "\n" - . ' ' . "\n" - . '
' . $strError . '
' . "\n" - . '
' . "\n" - . ' ' . "\n" - . ' ' . wordwrap($strWebServerUploadDirectoryError,80,'
 ') . '' . "\n" - . '
' . "\n" - . ' ' . "\n"; - } -} // end if (web-server upload directory) -echo "\n"; - -// Encoding setting form appended by Y.Kawada -if (function_exists('PMA_set_enc_form')) { - echo PMA_set_enc_form(' '); - $form_items++; -} - -// Charset conversion options and submit button -if (($is_upload || $is_upload_dir) && - (!isset($is_inside_querywindow) || - (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' || $querydisplay_tab == 'full'))) - // It's possible that $db is empty: no db was selected on the left - // panel and the user wants to execute a .sql file to create one) - // && isset($db) && $db != ''){ - ){ -/* - if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) { - $form_items++; - echo '
' . "\n"; - $temp_charset = reset($cfg['AvailableCharsets']); - echo $strCharsetOfFile . "\n" - . '
' . "\n" . ' '; - echo '
' . "\n"; - } // end if (recoding) -*/ - echo ' ' . "\n"; - if (PMA_MYSQL_INT_VERSION < 40100 && $cfg['AllowAnywhereRecoding'] && $allow_recoding) { - $temp_charset = reset($cfg['AvailableCharsets']); - echo ' ' . $strCharsetOfFile - . ' ' . "\n" . ' '; - } // end if (recoding) - else if (PMA_MYSQL_INT_VERSION >= 40100) { - echo $strCharsetOfFile . "\n" - . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', NULL, 'utf8', FALSE); - } - echo ' ' . "\n" - . ' ' . "\n" - . ' ' . "\n\n"; -} - -// Bookmark Support -$bookmark_go = FALSE; -if (!isset($is_inside_querywindow) || - (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full'))) { - if ($cfg['Bookmark']['db'] && $cfg['Bookmark']['table']) { - if (($bookmark_list = PMA_listBookmarks($db, $cfg['Bookmark'])) && count($bookmark_list) > 0) { - $form_items++; - echo ' ' . "\n"; - echo ' ' . "\n"; - echo " " . ((isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && $querydisplay_tab == 'full') || !isset($is_inside_querywindow) ? "$strOr" : '') . " $strBookmarkQuery: \n"; - echo ' ' . "\n"; - if (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE) { - $querybox_hidden_fields .= ' ' . "\n"; - } - - echo ' ' . "\n"; - echo ' ' . "   \n"; - echo ' ' . $strVar; - echo ' ' . $cfg['ReplaceHelpImg'] ? '' . $strDocu . '' : '(' . $strDocu . ')'; - echo ':
' . "\n"; - echo ' ' . "\n"; - echo '  ' . "\n"; - echo '  ' . "\n"; - echo '
' . "\n"; - echo ' ' . "\n"; - echo '
' . "\n"; - $bookmark_go = TRUE; - } - } -} - -if (!isset($is_inside_querywindow) || (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && (($querydisplay_tab == 'files') || $querydisplay_tab == 'sql' || $querydisplay_tab == 'full' || ($querydisplay_tab == 'history' && $bookmark_go)))) { - if ($form_items > 0) { - if ( $cfg['Bookmark']['db'] - && $cfg['Bookmark']['table'] - && (!isset($is_inside_querywindow) - || ( isset($is_inside_querywindow) - && $is_inside_querywindow == TRUE - && isset($querydisplay_tab) - //&& $querydisplay_tab != 'history'))) { - && $querydisplay_tab == 'sql'))) { -?> - > - align="left">: - - > - : - - - - > -   :
-    - -
- - - -' . "\n"; - // TODO: Add a more complete warning that no items (like for file import) where found. - // (After 2.5.2 release!) - echo $strWebServerUploadDirectoryError; - echo ' ' . "\n"; - } -} -echo ' ' . "\n"; -echo $querybox_hidden_fields; -echo ' '; -if ($upload_dir_error!='') { - echo $upload_dir_error; -} -?> -
> - - -    
> - - - '; - } else { - echo ''; - } - ?> - - -
> -' . $strOr . '' : '') - . ' ' . $strLocationTextfile . ': ' . "\n"; -?> -
' . "\n"; - echo ' '; - echo '
> - -
-
- -\n"; -if (!isset($is_inside_querywindow) || - (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE && isset($querydisplay_tab) && ($querydisplay_tab == 'files' || $querydisplay_tab == 'full')) && isset($db) && $db != '') { - - // loic1: displays import dump feature only if file upload available - $ldi_target = 'ldi_table.php?' . $url_query . (isset($is_inside_querywindow) && $is_inside_querywindow == TRUE ? '&focus_querywindow=true' : ''); - - if ($is_upload && isset($db) && isset($table)) { - //if (!isset($is_inside_querywindow) || !$is_inside_querywindow) echo "
  • \n"; - if ($cfg['PropertiesIconic']) { - $imgInsertTextfiles = '' . $strInsertTextfiles. ''; - }else{ - $imgInsertTextfiles = ''; - } - ?> - - - - - - - - - - - - - \n"; - } -} -echo "\n"; +PMA_sqlQueryForm( $query_to_display, $querydisplay_tab ); ?>