File: tbl_find_replace.php

package info (click to toggle)
phpmyadmin 4%3A4.2.12-2%2Bdeb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 34,968 kB
  • ctags: 28,057
  • sloc: php: 133,196; sql: 510; sh: 240; makefile: 192; python: 187
file content (63 lines) | stat: -rw-r--r-- 1,658 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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_URL_getCommon($db, $table);
// Displays the find and replace form
$htmlOutput .= $table_search->getSelectionForm($goto);
$response->addHTML($htmlOutput);

?>