From aa7136b7a64fdd65da42f4abb4c5dc53ce353497 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Mon, 12 Dec 2005 18:56:31 +0000 Subject: [PATCH] revised --- ChangeLog | 1 + db_search.php | 290 ++++++++++++++++++++------------------------------ 2 files changed, 114 insertions(+), 177 deletions(-) diff --git a/ChangeLog b/ChangeLog index dfd7be98c..faab6202e 100755 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ $Source$ - check magic_quotes only once in common.inc.php * css/phpmyadmin.css.php, tbl_properties_operations.php: styled table operations dialog + * db_search.php: revised 2005-12-11 Marc Delisle * libraries/tbl_properties_links.inc.php: bug #1375752, diff --git a/db_search.php b/db_search.php index 67bf62646..33df2838b 100644 --- a/db_search.php +++ b/db_search.php @@ -16,14 +16,12 @@ if (!$cfg['UseDbSearch']) { PMA_mysqlDie($strAccessDenied, '', FALSE, $err_url); } // end if $url_query .= '&goto=db_search.php'; - +$url_params['goto'] = 'db_search.php'; /** * Get the list of tables from the current database */ -$tables = PMA_DBI_get_tables($db); -$num_tables = count($tables); - +$tables = PMA_DBI_get_tables($GLOBALS['db']); /** * Displays top links @@ -35,7 +33,7 @@ require('./libraries/db_details_links.inc.php'); /** * 1. Main search form has been submitted */ -if (isset($submit_search)) { +if (isset($_REQUEST['submit_search'])) { /** * Builds the SQL search query @@ -127,139 +125,87 @@ if (isset($submit_search)) { /** * Displays the results */ - if (!empty($search_str) && !empty($search_option)) { + if (!empty($_REQUEST['search_str']) && !empty($_REQUEST['search_option'])) { - $original_search_str = $search_str; - $search_str = PMA_sqlAddslashes($search_str, TRUE); + $original_search_str = $_REQUEST['search_str']; + $search_str = PMA_sqlAddslashes($_REQUEST['search_str'], TRUE); // Get the true string to display as option's comment - switch ($search_option) { + switch ($_REQUEST['search_option']) { case 1: $option_str = ' (' . $strSearchOption1 . ')'; + $search_option = 1; break; case 2: $option_str = ' (' . $strSearchOption2 . ')'; + $search_option = 2; break; case 3: $option_str = ' (' . $strSearchOption3 . ')'; + $search_option = 3; break; case 4: $option_str = ' (' . $strSearchOption4 . ')'; + $search_option = 4; break; } // end switch - // If $table is defined or if there is only one table in $table_select - // set $onetable to the table's name (display is different if there is - // only one table). - // - // Recall: - // $tables is an array with all tables in database $db - // $num_tables is the size of $tables - if (isset($table)) { - $onetable = $table; - } - else if (isset($table_select)) { - $num_selectedtables = count($table_select); - if ($num_selectedtables == 1) { - $onetable = $table_select[0]; - } - } - else if ($num_tables == 1) { - $onetable = $tables[0]; - } - else { - for ($i = 0; $i < $num_tables; $i++) { - $table_select[] = $tables[$i]; - } - $num_selectedtables = $num_tables; - } // end if... else if... else - ?> -
+ $this_url_params = array( + 'db' => $GLOBALS['db'], + 'goto' => 'db_details.php', + 'pos' => 0, + 'is_js_confirmed' => 0, + ); - ' . "\n" + .'' . "\n" + .'' . "\n"; - // Only one table defined in an variable $onetable - if (isset($onetable)) { - // Displays search string - echo ' ' . sprintf($strSearchResultsFor, htmlspecialchars($original_search_str), $option_str) . "\n"; - echo '
' . "\n"; + $num_search_result_total = 0; + $odd_row = true; + foreach ( $_REQUEST['table_select'] as $each_table ) { // Gets the SQL statements - $newsearchsqls = PMA_getSearchSqls($onetable, $search_str, $search_option); + $newsearchsqls = PMA_getSearchSqls($each_table, + $search_str, $search_option); // Executes the "COUNT" statement - $res = PMA_DBI_query($newsearchsqls['select_count']); - $res_cnt = PMA_DBI_fetch_assoc($res); - $res_cnt = $res_cnt['count']; - PMA_DBI_free_result($res); - $num_search_result_total = $res_cnt; + $res_cnt = PMA_DBI_fetch_value($newsearchsqls['select_count']); + $num_search_result_total += $res_cnt; - echo ' ' . "\n" - . '
' . "\n" - . '
' . "\n" + .sprintf($strSearchResultsFor, + htmlspecialchars($original_search_str), $option_str) . "\n" + .'
\n"; + echo '' + .'\n"; if ($res_cnt > 0) { - echo '\n"; + $this_url_params['sql_query'] = $newsearchsqls['select_fields']; + echo '\n"; - echo '\n"; + $this_url_params['sql_query'] = $newsearchsqls['delete']; + echo '\n"; - } // end if - echo '
' . sprintf($strNumSearchResultsInTable, $res_cnt, htmlspecialchars($onetable)) . "
' . sprintf($strNumSearchResultsInTable, $res_cnt, + htmlspecialchars($each_table)) . "' . PMA_linkOrButton('sql.php?' . $url_sql_query - . '&sql_query=' .urlencode($newsearchsqls['select_fields']), - $strBrowse, '') . "' . PMA_linkOrButton( + 'sql.php' . PMA_generate_common_url($this_url_params), + $strBrowse, '') . "' . PMA_linkOrButton('sql.php?' . $url_sql_query - . '&sql_query=' .urlencode($newsearchsqls['delete']), - $strDelete, $newsearchsqls['delete']) . "' . PMA_linkOrButton( + 'sql.php' . PMA_generate_common_url($this_url_params), + $strDelete, $newsearchsqls['delete']) . "
' . "\n"; - } // end only one table + } else { + echo ' ' . "\n" + .' ' . "\n"; + }// end if else + $odd_row = ! $odd_row; + echo '' . "\n"; + } // end for - // Several tables defined in the array $table_select - else if (isset($table_select)) { - // Displays search string - echo ' ' . sprintf($strSearchResultsFor, htmlspecialchars($original_search_str), $option_str) . "\n"; - echo ' ' . "\n"; - echo '

' . sprintf($strNumSearchResultsTotal, $num_search_result_total) . '

' . "\n"; - } // end several tables - - echo "\n"; - ?> -
- 1 ) { + echo '

' . sprintf($strNumSearchResultsTotal, + $num_search_result_total) . '

' . "\n"; + } } // end if (!empty($search_str) && !empty($search_option)) } // end 1. @@ -276,87 +222,77 @@ if (empty($search_option)) { $search_option = 1; } ?> -
- + +
+ - - - +
+ + - - - - - - - - + + 1 - - - - + - - - - + +
-  
-
- -
-   - - /> *
- /> *
- />
- />
+
+ /> + 1
+ /> + 1
+ /> +
+ /> + +

- *  -
-   - +
+ 1) { - $i = 0; +echo ' ' . "\n"; - while ($i < $num_tables) { - if (!empty($unselectall)) { - $is_selected = ''; - } - elseif ( ( isset($table_select) && in_array($tables[$i], $table_select) ) - || ! empty($selectall) - || ( isset($onetable) && $onetable == $tables[$i]) ) { - $is_selected = ' selected="selected"'; - } - else { - $is_selected = ''; - } - - echo ' ' . "\n"; - $i++; - } // end while - echo ' ' . "\n"; - $strDoSelectAll = '' . $strSelectAll . '' - . ' / ' - . '' . $strUnselectAll . ''; -} -else { - echo "\n"; - echo ' ' . htmlspecialchars($tables[0]) . "\n"; - echo ' ' . "\n"; -} // end if... else... - -echo"\n"; + echo ' ' . "\n"; +} // end while +echo ' ' . "\n"; +$strDoSelectAll = '' . $strSelectAll . '' + . ' / ' + . '' . $strUnselectAll . ''; ?>
+
+
+
+ +