From 7ab40e1deb8bdc9a4f7405c7e92784de34bba476 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Fri, 29 Jun 2012 22:39:12 +0530 Subject: [PATCH 1/8] Variable improvement left in 417856ee9f7e1aa94721 --- db_search.php | 4 ++-- libraries/db_search.lib.php | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/db_search.php b/db_search.php index e96823447a..440e713dbd 100644 --- a/db_search.php +++ b/db_search.php @@ -58,7 +58,7 @@ if (empty($_REQUEST['criteriaSearchType']) unset($_REQUEST['submit_search']); } else { $criteriaSearchType = (int) $_REQUEST['criteriaSearchType']; - $option_str = $searchTypes[$_REQUEST['criteriaSearchType']]; + $searchTypeDescription = $searchTypes[$_REQUEST['criteriaSearchType']]; } if (empty($_REQUEST['criteriaSearchString']) @@ -118,7 +118,7 @@ if ( $GLOBALS['is_ajax_request'] != true) { if (isset($_REQUEST['submit_search'])) { $response->addHTML( PMA_dbSearchGetSearchResults( - $criteriaTables, $searched, $option_str, + $criteriaTables, $searched, $searchTypeDescription, $criteriaSearchString, $criteriaSearchType, (! empty($criteriaColumnName) ? $criteriaColumnName : '') ) diff --git a/libraries/db_search.lib.php b/libraries/db_search.lib.php index 14032db9dd..17e36fd36e 100644 --- a/libraries/db_search.lib.php +++ b/libraries/db_search.lib.php @@ -125,19 +125,20 @@ function PMA_dbSearchGetWhereClause($table, $search_words, $criteriaSearchType, /** * Displays database search results * - * @param array $criteriaTables Tables on which search is to be performed - * @param string $searched The search word/phrase/regexp - * @param string $option_str Type of search - * @param string $criteriaSearchString The string to search - * @param integer $criteriaSearchType Type of search - * (1 -> 1 word at least, 2 -> all words, - * 3 -> exact string, 4 -> regexp) - * @param string $criteriaColumnName Restrict the search to this column + * @param array $criteriaTables Tables on which search is to be performed + * @param string $searched The search word/phrase/regexp + * @param string $searchTypeDescription Type of search + * @param string $criteriaSearchString The string to search + * @param integer $criteriaSearchType Type of search + * (1 -> 1 word at least, 2 -> all words, + * 3 -> exact string, 4 -> regexp) + * @param string $criteriaColumnName Restrict the search to this column * * @return string HTML for search results */ -function PMA_dbSearchGetSearchResults($criteriaTables, $searched, $option_str, - $criteriaSearchString, $criteriaSearchType, $criteriaColumnName = null +function PMA_dbSearchGetSearchResults($criteriaTables, $searched, + $searchTypeDescription, $criteriaSearchString, $criteriaSearchType, + $criteriaColumnName = null ) { $html_output = ''; // Displays search string @@ -146,7 +147,7 @@ function PMA_dbSearchGetSearchResults($criteriaTables, $searched, $option_str, . '' . sprintf( __('Search results for "%s" %s:'), - $searched, $option_str + $searched, $searchTypeDescription ) . ''; From 362213af2023f24f87c45335a38ffa14863227f5 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 30 Jun 2012 09:25:19 +0530 Subject: [PATCH 2/8] Move variables to appropriate function --- libraries/db_search.lib.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libraries/db_search.lib.php b/libraries/db_search.lib.php index 17e36fd36e..0eaf37d933 100644 --- a/libraries/db_search.lib.php +++ b/libraries/db_search.lib.php @@ -42,15 +42,10 @@ function PMA_getSearchSqls($table, $criteriaColumnName, $criteriaSearchString, // Search words or pattern $search_words = (($criteriaSearchType > 2) ? array($criteriaSearchString) : explode(' ', $criteriaSearchString)); - - $like_or_regex = (($criteriaSearchType == 4) ? 'REGEXP' : 'LIKE'); - $automatic_wildcard = (($criteriaSearchType < 3) ? '%' : ''); - + // Gets where clause for the query $where_clause = PMA_dbSearchGetWhereClause( - $table, $search_words, $criteriaSearchType, $criteriaColumnName, - $like_or_regex, $automatic_wildcard + $table, $search_words, $criteriaSearchType, $criteriaColumnName ); - // Builds complete queries $sql['select_columns'] = $sqlstr_select . ' * ' . $sqlstr_from . $where_clause; // here, I think we need to still use the COUNT clause, even for @@ -71,17 +66,17 @@ function PMA_getSearchSqls($table, $criteriaColumnName, $criteriaSearchString, * (1 -> 1 word at least, 2 -> all words, * 3 -> exact string, 4 -> regexp) * @param string $criteriaColumnName Restrict the search to this column - * @param string $like_or_regex Whether to use 'LIKE' or 'REGEXP' - * @param string $automatic_wildcard Use automatic wildcard * * @return string The generated where clause */ function PMA_dbSearchGetWhereClause($table, $search_words, $criteriaSearchType, - $criteriaColumnName, $like_or_regex, $automatic_wildcard + $criteriaColumnName ) { $where_clause = ''; // Columns to select $allColumns = PMA_DBI_get_columns($GLOBALS['db'], $table); + $like_or_regex = (($criteriaSearchType == 4) ? 'REGEXP' : 'LIKE'); + $automatic_wildcard = (($criteriaSearchType < 3) ? '%' : ''); $likeClauses = array(); foreach ($search_words as $search_word) { From 82ff5dc5e065e142b501ec5c91c4b8b5b6ce08ab Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 30 Jun 2012 11:28:46 +0530 Subject: [PATCH 3/8] Improve usage visibility of criteriaSearchString variable --- db_search.php | 22 +++++--------- libraries/db_search.lib.php | 60 ++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/db_search.php b/db_search.php index 440e713dbd..588b17203f 100644 --- a/db_search.php +++ b/db_search.php @@ -64,19 +64,10 @@ if (empty($_REQUEST['criteriaSearchType']) if (empty($_REQUEST['criteriaSearchString']) || ! is_string($_REQUEST['criteriaSearchString']) ) { + $criteriaSearchString = ''; unset($_REQUEST['submit_search']); - $searched = ''; } else { - $searched = htmlspecialchars($_REQUEST['criteriaSearchString']); - // For "as regular expression" (search option 4), we should not treat - // this as an expression that contains a LIKE (second parameter of - // PMA_sqlAddSlashes()). - // - // Usage example: If user is seaching for a literal $ in a regexp search, - // he should enter \$ as the value. - $criteriaSearchString = PMA_sqlAddSlashes( - $_REQUEST['criteriaSearchString'], ($criteriaSearchType == 4 ? false : true) - ); + $criteriaSearchString = $_REQUEST['criteriaSearchString']; } $criteriaTables = array(); @@ -118,8 +109,8 @@ if ( $GLOBALS['is_ajax_request'] != true) { if (isset($_REQUEST['submit_search'])) { $response->addHTML( PMA_dbSearchGetSearchResults( - $criteriaTables, $searched, $searchTypeDescription, - $criteriaSearchString, $criteriaSearchType, + $criteriaTables, $searchTypeDescription, + $criteriaSearchString, $criteriaSearchType, (! empty($criteriaColumnName) ? $criteriaColumnName : '') ) ); @@ -136,8 +127,9 @@ if ($GLOBALS['is_ajax_request'] == true) { // Add search form $response->addHTML( PMA_dbSearchGetSelectionForm( - $searched, $criteriaSearchType, $tables_names_only, $criteriaTables, - $url_params, (! empty($criteriaColumnName) ? $criteriaColumnName : '') + $criteriaSearchString, $criteriaSearchType, $tables_names_only, + $criteriaTables, $url_params, + (! empty($criteriaColumnName) ? $criteriaColumnName : '') ) ); ?> diff --git a/libraries/db_search.lib.php b/libraries/db_search.lib.php index 0eaf37d933..3638270630 100644 --- a/libraries/db_search.lib.php +++ b/libraries/db_search.lib.php @@ -14,7 +14,7 @@ if (! defined('PHPMYADMIN')) { * * @param string $table The table name * @param string $criteriaColumnName Restrict the search to this column - * @param string $criteriaSearchString The string to search + * @param string $criteriaSearchString The search word/phrase/regexp to be searched * @param integer $criteriaSearchType Type of search * (1 -> 1 word at least, 2 -> all words, * 3 -> exact string, 4 -> regexp) @@ -39,12 +39,9 @@ function PMA_getSearchSqls($table, $criteriaColumnName, $criteriaSearchString, // Table to use $sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table); - // Search words or pattern - $search_words = (($criteriaSearchType > 2) - ? array($criteriaSearchString) : explode(' ', $criteriaSearchString)); // Gets where clause for the query $where_clause = PMA_dbSearchGetWhereClause( - $table, $search_words, $criteriaSearchType, $criteriaColumnName + $table, $criteriaSearchString, $criteriaSearchType, $criteriaColumnName ); // Builds complete queries $sql['select_columns'] = $sqlstr_select . ' * ' . $sqlstr_from . $where_clause; @@ -60,24 +57,33 @@ function PMA_getSearchSqls($table, $criteriaColumnName, $criteriaSearchString, /** * Provides where clause for bulding SQL query * - * @param string $table the table name - * @param integer $search_words Search words or pattern - * @param integer $criteriaSearchType Type of search - * (1 -> 1 word at least, 2 -> all words, - * 3 -> exact string, 4 -> regexp) - * @param string $criteriaColumnName Restrict the search to this column + * @param string $table The table name + * @param integer $criteriaSearchString The search word/phrase/regexp to be searched + * @param integer $criteriaSearchType Type of search + * (1 -> 1 word at least, 2 -> all words, + * 3 -> exact string, 4 -> regexp) + * @param string $criteriaColumnName Restrict the search to this column * * @return string The generated where clause */ -function PMA_dbSearchGetWhereClause($table, $search_words, $criteriaSearchType, - $criteriaColumnName +function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, + $criteriaSearchType, $criteriaColumnName ) { $where_clause = ''; // Columns to select $allColumns = PMA_DBI_get_columns($GLOBALS['db'], $table); + $likeClauses = array(); $like_or_regex = (($criteriaSearchType == 4) ? 'REGEXP' : 'LIKE'); $automatic_wildcard = (($criteriaSearchType < 3) ? '%' : ''); - $likeClauses = array(); + // For "as regular expression" (search option 4), LIKE won't be used + // Usage example: If user is seaching for a literal $ in a regexp search, + // he should enter \$ as the value. + $criteriaSearchString = PMA_sqlAddSlashes( + $_REQUEST['criteriaSearchString'], ($criteriaSearchType == 4 ? false : true) + ); + // Search words or pattern + $search_words = (($criteriaSearchType > 2) + ? array($criteriaSearchString) : explode(' ', $criteriaSearchString)); foreach ($search_words as $search_word) { // Eliminates empty values @@ -121,9 +127,8 @@ function PMA_dbSearchGetWhereClause($table, $search_words, $criteriaSearchType, * Displays database search results * * @param array $criteriaTables Tables on which search is to be performed - * @param string $searched The search word/phrase/regexp * @param string $searchTypeDescription Type of search - * @param string $criteriaSearchString The string to search + * @param string $criteriaSearchString The search word/phrase/regexp to be searched * @param integer $criteriaSearchType Type of search * (1 -> 1 word at least, 2 -> all words, * 3 -> exact string, 4 -> regexp) @@ -131,9 +136,8 @@ function PMA_dbSearchGetWhereClause($table, $search_words, $criteriaSearchType, * * @return string HTML for search results */ -function PMA_dbSearchGetSearchResults($criteriaTables, $searched, - $searchTypeDescription, $criteriaSearchString, $criteriaSearchType, - $criteriaColumnName = null +function PMA_dbSearchGetSearchResults($criteriaTables, $searchTypeDescription, + $criteriaSearchString, $criteriaSearchType, $criteriaColumnName = null ) { $html_output = ''; // Displays search string @@ -142,7 +146,7 @@ function PMA_dbSearchGetSearchResults($criteriaTables, $searched, . '' . sprintf( __('Search results for "%s" %s:'), - $searched, $searchTypeDescription + htmlspecialchars($criteriaSearchString), $searchTypeDescription ) . ''; @@ -242,16 +246,16 @@ function PMA_dbSearchGetResultsRow($each_table, $newsearchsqls, $odd_row) /** * Provides the main search form's html * - * @param string $searched Keyword/Regular expression to be searched - * @param integer $criteriaSearchType Type of search (one word, phrase etc.) - * @param array $tables_names_only Names of all tables - * @param array $criteriaTables Tables on which search is to be performed - * @param array $url_params URL parameters - * @param string $criteriaColumnName Restrict the search to this column + * @param string $criteriaSearchString Keyword/Regular expression earlier entered + * @param integer $criteriaSearchType Type of search (one word, phrase etc.) + * @param array $tables_names_only Names of all tables + * @param array $criteriaTables Tables on which search is to be performed + * @param array $url_params URL parameters + * @param string $criteriaColumnName Restrict the search to this column * * @return string HTML for selection form */ -function PMA_dbSearchGetSelectionForm($searched, $criteriaSearchType, +function PMA_dbSearchGetSelectionForm($criteriaSearchString, $criteriaSearchType, $tables_names_only, $criteriaTables, $url_params, $criteriaColumnName = null ) { $html_output = ''; @@ -268,7 +272,7 @@ function PMA_dbSearchGetSelectionForm($searched, $criteriaSearchType, $html_output .= '' . __('Words or values to search for (wildcard: "%"):') . ''; $html_output .= ''; + . ' value="' . htmlspecialchars($criteriaSearchString) . '" />'; $html_output .= ''; // choices for types of search $html_output .= ''; From 4203ca5d5429518ab0e301d1c475dd31b4ab3367 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 30 Jun 2012 16:13:57 +0530 Subject: [PATCH 4/8] Add some more comments --- libraries/db_search.lib.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/db_search.lib.php b/libraries/db_search.lib.php index 3638270630..99a4f3f137 100644 --- a/libraries/db_search.lib.php +++ b/libraries/db_search.lib.php @@ -73,6 +73,7 @@ function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, // Columns to select $allColumns = PMA_DBI_get_columns($GLOBALS['db'], $table); $likeClauses = array(); + // Based on search type, decide like/regex & '%'/'' $like_or_regex = (($criteriaSearchType == 4) ? 'REGEXP' : 'LIKE'); $automatic_wildcard = (($criteriaSearchType < 3) ? '%' : ''); // For "as regular expression" (search option 4), LIKE won't be used @@ -81,8 +82,8 @@ function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, $criteriaSearchString = PMA_sqlAddSlashes( $_REQUEST['criteriaSearchString'], ($criteriaSearchType == 4 ? false : true) ); - // Search words or pattern - $search_words = (($criteriaSearchType > 2) + // Extract search words or pattern + $search_words = (($criteriaSearchType > 2) ? array($criteriaSearchString) : explode(' ', $criteriaSearchString)); foreach ($search_words as $search_word) { @@ -111,7 +112,7 @@ function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, $likeClauses[] = implode(' OR ', $likeClausesPerColumn); } } // end for - + // Use 'OR' if 'at least one word' is to be searched, else use 'AND' $implode_str = ($criteriaSearchType == 1 ? ' OR ' : ' AND '); if ( empty($likeClauses)) { // this could happen when the "inside column" does not exist @@ -162,13 +163,14 @@ function PMA_dbSearchGetSearchResults($criteriaTables, $searchTypeDescription, // Executes the "COUNT" statement $res_cnt = PMA_DBI_fetch_value($newsearchsqls['select_count']); $num_search_result_total += $res_cnt; + // Gets the result row's HTML for a table $html_output .= PMA_dbSearchGetResultsRow( $each_table, $newsearchsqls, $odd_row ); $odd_row = ! $odd_row; } // end for $html_output .= ''; - + // Displays total number of matches if (count($criteriaTables) > 1) { $html_output .= '

'; $html_output .= sprintf( @@ -205,6 +207,7 @@ function PMA_dbSearchGetResultsRow($each_table, $newsearchsqls, $odd_row) $res_cnt = PMA_DBI_fetch_value($newsearchsqls['select_count']); // Start forming search results row $html_output = ''; + // Displays results count for a table $html_output .= ''; $html_output .= sprintf( _ngettext( @@ -214,10 +217,10 @@ function PMA_dbSearchGetResultsRow($each_table, $newsearchsqls, $odd_row) $res_cnt, htmlspecialchars($each_table) ); $html_output .= ''; - + // Displays browse/delete link if result count > 0 if ($res_cnt > 0) { $this_url_params['sql_query'] = $newsearchsqls['select_columns']; - $browse_result_path = 'sql.php' . PMA_generate_common_url($this_url_params); + $browse_result_path = 'sql.php' . PMA_generate_common_url($this_url_params); $html_output .= ' 1))) . '#db_search"' . ' onclick="setSelectOptions(\'db_search\', \'criteriaTables[]\', true); return false;">' . __('Select All') . '' @@ -316,6 +320,7 @@ function PMA_dbSearchGetSelectionForm($criteriaSearchString, $criteriaSearchType . ' onclick="setSelectOptions(\'db_search\', \'criteriaTables[]\', false); return false;">' . __('Unselect All') . ''; $html_output .= ''; $html_output .= '' . $alter_select . ''; + // Inputbox for column name entry $html_output .= ''; $html_output .= '' . __('Inside column:') . ''; $html_output .= ' Date: Sat, 30 Jun 2012 16:39:52 +0530 Subject: [PATCH 5/8] Some coding style improvements --- libraries/db_search.lib.php | 42 ++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/libraries/db_search.lib.php b/libraries/db_search.lib.php index 99a4f3f137..751e7174ad 100644 --- a/libraries/db_search.lib.php +++ b/libraries/db_search.lib.php @@ -119,7 +119,9 @@ function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, // in any selected tables $where_clause = ' WHERE FALSE'; } else { - $where_clause = ' WHERE (' . implode(') ' . $implode_str . ' (', $likeClauses) . ')'; + $where_clause = ' WHERE (' + . implode(') ' . $implode_str . ' (', $likeClauses) + . ')'; } return $where_clause; } @@ -220,7 +222,7 @@ function PMA_dbSearchGetResultsRow($each_table, $newsearchsqls, $odd_row) // Displays browse/delete link if result count > 0 if ($res_cnt > 0) { $this_url_params['sql_query'] = $newsearchsqls['select_columns']; - $browse_result_path = 'sql.php' . PMA_generate_common_url($this_url_params); + $browse_result_path = 'sql.php' . PMA_generate_common_url($this_url_params); $html_output .= '' . __('Find:') . ''; $html_output .= ''; $choices = array( - '1' => __('at least one of the words') . PMA_showHint(__('Words are separated by a space character (" ").')), - '2' => __('all words') . PMA_showHint(__('Words are separated by a space character (" ").')), + '1' => __('at least one of the words') + . PMA_showHint(__('Words are separated by a space character (" ").')), + '2' => __('all words') + . PMA_showHint(__('Words are separated by a space character (" ").')), '3' => __('the exact phrase'), - '4' => __('as regular expression') . ' ' . PMA_showMySQLDocu('Regexp', 'Regexp') + '4' => __('as regular expression') + . ' ' . PMA_showMySQLDocu('Regexp', 'Regexp') ); // 4th parameter set to true to add line breaks // 5th parameter set to false to avoid htmlspecialchars() escaping in the label @@ -311,20 +316,27 @@ function PMA_dbSearchGetSelectionForm($criteriaSearchString, $criteriaSearchType . ''; } // end for $html_output .= ''; - // Displays 'select all' and 'unselect all' links - $alter_select - = '' . __('Select All') . '' - . ' / ' - . '' . __('Unselect All') . ''; $html_output .= ''; + // Displays 'select all' and 'unselect all' links + $alter_select = '' + . __('Select All') . '  / '; + $alter_select .= '' + . __('Unselect All') . ''; $html_output .= '' . $alter_select . ''; // Inputbox for column name entry $html_output .= ''; $html_output .= '' . __('Inside column:') . ''; $html_output .= ''; $html_output .= ''; $html_output .= ''; @@ -353,8 +365,8 @@ function getResultDivs() $html_output .= ''; // div for browsing results $html_output .= '

'; - $html_output .= ''; + $html_output .= ''; $html_output .= '
'; $html_output .= '
'; $html_output .= '
'; From 9281d8b3a464882ef8566698fb3efedabc1449cc Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 30 Jun 2012 19:29:47 +0530 Subject: [PATCH 6/8] Fix doc comment --- libraries/db_search.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/db_search.lib.php b/libraries/db_search.lib.php index 751e7174ad..30ad0fa7a5 100644 --- a/libraries/db_search.lib.php +++ b/libraries/db_search.lib.php @@ -130,7 +130,7 @@ function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, * Displays database search results * * @param array $criteriaTables Tables on which search is to be performed - * @param string $searchTypeDescription Type of search + * @param string $searchTypeDescription Description for search type * @param string $criteriaSearchString The search word/phrase/regexp to be searched * @param integer $criteriaSearchType Type of search * (1 -> 1 word at least, 2 -> all words, From 81d15e860b647f176de968aae9cc1c64c1ffc0d0 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Sat, 30 Jun 2012 19:36:47 +0530 Subject: [PATCH 7/8] Fix typo in 82ff5dc5e065e142b501 --- libraries/db_search.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/db_search.lib.php b/libraries/db_search.lib.php index 30ad0fa7a5..e043cb2aa2 100644 --- a/libraries/db_search.lib.php +++ b/libraries/db_search.lib.php @@ -80,7 +80,7 @@ function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, // Usage example: If user is seaching for a literal $ in a regexp search, // he should enter \$ as the value. $criteriaSearchString = PMA_sqlAddSlashes( - $_REQUEST['criteriaSearchString'], ($criteriaSearchType == 4 ? false : true) + $criteriaSearchString, ($criteriaSearchType == 4 ? false : true) ); // Extract search words or pattern $search_words = (($criteriaSearchType > 2) From 0a8dd19414ed5f3bdbbf2d149eaad4566057e83f Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Wed, 4 Jul 2012 08:55:01 +0530 Subject: [PATCH 8/8] Use PMA_CommonFunctions in libraries/db_search.lib.php --- libraries/db_search.lib.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/libraries/db_search.lib.php b/libraries/db_search.lib.php index e043cb2aa2..5720246dc1 100644 --- a/libraries/db_search.lib.php +++ b/libraries/db_search.lib.php @@ -33,12 +33,14 @@ if (! defined('PHPMYADMIN')) { function PMA_getSearchSqls($table, $criteriaColumnName, $criteriaSearchString, $criteriaSearchType ) { + $common_functions = PMA_CommonFunctions::getInstance(); // Statement types $sqlstr_select = 'SELECT'; $sqlstr_delete = 'DELETE'; // Table to use $sqlstr_from = ' FROM ' - . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table); + . $common_functions->backquote($GLOBALS['db']) . '.' + . $common_functions->backquote($table); // Gets where clause for the query $where_clause = PMA_dbSearchGetWhereClause( $table, $criteriaSearchString, $criteriaSearchType, $criteriaColumnName @@ -69,6 +71,7 @@ function PMA_getSearchSqls($table, $criteriaColumnName, $criteriaSearchString, function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, $criteriaSearchType, $criteriaColumnName ) { + $common_functions = PMA_CommonFunctions::getInstance(); $where_clause = ''; // Columns to select $allColumns = PMA_DBI_get_columns($GLOBALS['db'], $table); @@ -79,7 +82,7 @@ function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, // For "as regular expression" (search option 4), LIKE won't be used // Usage example: If user is seaching for a literal $ in a regexp search, // he should enter \$ as the value. - $criteriaSearchString = PMA_sqlAddSlashes( + $criteriaSearchString = $common_functions->sqlAddSlashes( $criteriaSearchString, ($criteriaSearchType == 4 ? false : true) ); // Extract search words or pattern @@ -100,8 +103,9 @@ function PMA_dbSearchGetWhereClause($table, $criteriaSearchString, ) { // Drizzle has no CONVERT and all text columns are UTF-8 $column = ((PMA_DRIZZLE) - ? PMA_backquote($column['Field']) - : 'CONVERT(' . PMA_backquote($column['Field']) . ' USING utf8)'); + ? $common_functions->backquote($column['Field']) + : 'CONVERT(' . $common_functions->backquote($column['Field']) + . ' USING utf8)'); $likeClausesPerColumn[] = $column . ' ' . $like_or_regex . ' ' . "'" . $automatic_wildcard . $search_word . $automatic_wildcard @@ -263,6 +267,7 @@ function PMA_dbSearchGetResultsRow($each_table, $newsearchsqls, $odd_row) function PMA_dbSearchGetSelectionForm($criteriaSearchString, $criteriaSearchType, $tables_names_only, $criteriaTables, $url_params, $criteriaColumnName = null ) { + $common_functions = PMA_CommonFunctions::getInstance(); $html_output = ''; $html_output .= '
__('at least one of the words') - . PMA_showHint(__('Words are separated by a space character (" ").')), + . $common_functions->showHint( + __('Words are separated by a space character (" ").') + ), '2' => __('all words') - . PMA_showHint(__('Words are separated by a space character (" ").')), + . $common_functions->showHint( + __('Words are separated by a space character (" ").') + ), '3' => __('the exact phrase'), '4' => __('as regular expression') - . ' ' . PMA_showMySQLDocu('Regexp', 'Regexp') + . ' ' . $common_functions->showMySQLDocu('Regexp', 'Regexp') ); // 4th parameter set to true to add line breaks // 5th parameter set to false to avoid htmlspecialchars() escaping in the label // since we have some HTML in some labels - $html_output .= PMA_getRadioFields( + $html_output .= $common_functions->getRadioFields( 'criteriaSearchType', $choices, $criteriaSearchType, true, false ); $html_output .= '';