Merge remote-tracking branch 'origin/master'
[phpmyadmin.git] / tbl_find_replace.php
blobc450cf62b508ce7472aa7f9050006aa1e69fda0d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Handles find and replace tab
6 * Displays find and replace form, allows previewing and do the replacing
8 * @package PhpMyAdmin
9 */
11 /**
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'],
26 $_POST['find'],
27 $_POST['replaceWith'],
28 $connectionCharSet
30 $response->addJSON('preview', $preview);
31 exit;
34 $header = $response->getHeader();
35 $scripts = $header->getScripts();
36 $scripts->addFile('tbl_find_replace.js');
38 // Show secondary level of tabs
39 $htmlOutput = $table_search->getSecondaryTabs();
41 if (isset($_POST['replace'])) {
42 $htmlOutput .= $table_search->replace(
43 $_POST['columnIndex'],
44 $_POST['findString'],
45 $_POST['replaceWith'],
46 $connectionCharSet
48 $htmlOutput .= PMA_Util::getMessage(
49 __('Your SQL query has been executed successfully'),
50 null, 'success'
54 if (! isset($goto)) {
55 $goto = $GLOBALS['cfg']['DefaultTabTable'];
57 // Defines the url to return to in case of error in the next sql statement
58 $err_url = $goto . '?' . PMA_URL_getCommon($db, $table);
59 // Displays the find and replace form
60 $htmlOutput .= $table_search->getSelectionForm($goto);
61 $response->addHTML($htmlOutput);