2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Handles find and replace tab
6 * Displays find and replace form, allows previewing and do the replacing
12 * Gets some core libraries
14 require_once 'libraries/common.inc.php';
15 require_once 'libraries/TableSearch.class.php';
17 $response = PMA_Response
::getInstance();
18 $table_search = new PMA_TableSearch($db, $table, "replace");
20 $connectionCharSet = $GLOBALS['dbi']->fetchValue(
21 "SHOW VARIABLES LIKE 'character_set_connection'", 0, 1
23 if (isset($_POST['find'])) {
24 $preview = $table_search->getReplacePreview(
25 $_POST['columnIndex'],
27 $_POST['replaceWith'],
31 $response->addJSON('preview', $preview);
35 $header = $response->getHeader();
36 $scripts = $header->getScripts();
37 $scripts->addFile('tbl_find_replace.js');
39 // Show secondary level of tabs
40 $htmlOutput = $table_search->getSecondaryTabs();
42 if (isset($_POST['replace'])) {
43 $htmlOutput .= $table_search->replace(
44 $_POST['columnIndex'],
46 $_POST['replaceWith'],
50 $htmlOutput .= PMA_Util
::getMessage(
51 __('Your SQL query has been executed successfully.'),
57 $goto = $GLOBALS['cfg']['DefaultTabTable'];
59 // Defines the url to return to in case of error in the next sql statement
60 $params = array('db' => $db, 'table' => $table);
61 $err_url = $goto . '?' . PMA_URL_getCommon($params);
62 // Displays the find and replace form
63 $htmlOutput .= $table_search->getSelectionForm($goto);
64 $response->addHTML($htmlOutput);