tbl_find_replace.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Handles find and replace tab
  5. *
  6. * Displays find and replace form, allows previewing and do the replacing
  7. *
  8. * @package PhpMyAdmin
  9. */
  10. /**
  11. * Gets some core libraries
  12. */
  13. require_once 'libraries/common.inc.php';
  14. require_once 'libraries/TableSearch.class.php';
  15. $response = PMA_Response::getInstance();
  16. $table_search = new PMA_TableSearch($db, $table, "replace");
  17. $connectionCharSet = $GLOBALS['dbi']->fetchValue(
  18. "SHOW VARIABLES LIKE 'character_set_connection'", 0, 1
  19. );
  20. if (isset($_POST['find'])) {
  21. $preview = $table_search->getReplacePreview(
  22. $_POST['columnIndex'],
  23. $_POST['find'],
  24. $_POST['replaceWith'],
  25. $connectionCharSet
  26. );
  27. $response->addJSON('preview', $preview);
  28. exit;
  29. }
  30. $header = $response->getHeader();
  31. $scripts = $header->getScripts();
  32. $scripts->addFile('tbl_find_replace.js');
  33. // Show secondary level of tabs
  34. $htmlOutput = $table_search->getSecondaryTabs();
  35. if (isset($_POST['replace'])) {
  36. $htmlOutput .= $table_search->replace(
  37. $_POST['columnIndex'],
  38. $_POST['findString'],
  39. $_POST['replaceWith'],
  40. $connectionCharSet
  41. );
  42. $htmlOutput .= PMA_Util::getMessage(
  43. __('Your SQL query has been executed successfully.'),
  44. null, 'success'
  45. );
  46. }
  47. if (! isset($goto)) {
  48. $goto = $GLOBALS['cfg']['DefaultTabTable'];
  49. }
  50. // Defines the url to return to in case of error in the next sql statement
  51. $err_url = $goto . '?' . PMA_URL_getCommon($db, $table);
  52. // Displays the find and replace form
  53. $htmlOutput .= $table_search->getSelectionForm($goto);
  54. $response->addHTML($htmlOutput);
  55. ?>