diff options
author | Kasun Chathuranga <chathuranga.jayaneththi@gmail.com> | 2013-06-26 19:00:28 +0400 |
---|---|---|
committer | Kasun Chathuranga <chathuranga.jayaneththi@gmail.com> | 2013-06-26 19:00:28 +0400 |
commit | 41a497d169acaf59f317346feba5d2081840f031 (patch) | |
tree | ede45473d7ea97e97a5556136854ae1da7cc6c82 /tbl_find_replace.php | |
parent | 6ebb42ace4f2593fa401c4b0ca2d4874b5942a7a (diff) |
Implement 'find and replace in a column' feature
Diffstat (limited to 'tbl_find_replace.php')
-rw-r--r-- | tbl_find_replace.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tbl_find_replace.php b/tbl_find_replace.php new file mode 100644 index 0000000000..7e7387aa39 --- /dev/null +++ b/tbl_find_replace.php @@ -0,0 +1,63 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Handles find and replace tab + * + * Displays find and replace form, allows previewing and do the replacing + * + * @package PhpMyAdmin + */ + +/** + * Gets some core libraries + */ +require_once 'libraries/common.inc.php'; +require_once 'libraries/TableSearch.class.php'; + +$response = PMA_Response::getInstance(); +$table_search = new PMA_TableSearch($db, $table, "replace"); + +$connectionCharSet = $GLOBALS['dbi']->fetchValue( + "SHOW VARIABLES LIKE 'character_set_connection'", 0, 1 +); +if (isset($_POST['find'])) { + $preview = $table_search->getReplacePreview( + $_POST['columnIndex'], + $_POST['find'], + $_POST['replaceWith'], + $connectionCharSet + ); + $response->addJSON('preview', $preview); + exit; +} + +$header = $response->getHeader(); +$scripts = $header->getScripts(); +$scripts->addFile('tbl_find_replace.js'); + +// Show secondary level of tabs +$htmlOutput = $table_search->getSecondaryTabs(); + +if (isset($_POST['replace'])) { + $htmlOutput .= $table_search->replace( + $_POST['columnIndex'], + $_POST['findString'], + $_POST['replaceWith'], + $connectionCharSet + ); + $htmlOutput .= PMA_Util::getMessage( + __('Your SQL query has been executed successfully'), + null, 'success' + ); +} + +if (! isset($goto)) { + $goto = $GLOBALS['cfg']['DefaultTabTable']; +} +// Defines the url to return to in case of error in the next sql statement +$err_url = $goto . '?' . PMA_generate_common_url($db, $table); +// Displays the find and replace form +$htmlOutput .= $table_search->getSelectionForm($goto); +$response->addHTML($htmlOutput); + +?> |