weekly release 4.0dev
[moodle.git] / admin / tool / replace / index.php
CommitLineData
20207b82 1<?php
fab6f7b7
PS
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Search and replace strings throughout all texts in the whole database
19 *
6c3ae510 20 * @package tool_replace
fab6f7b7
PS
21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
04337d75 24
cbad562e
PS
25define('NO_OUTPUT_BUFFERING', true);
26
fab6f7b7 27require_once('../../../config.php');
c9a49cea 28require_once($CFG->dirroot.'/course/lib.php');
29require_once($CFG->libdir.'/adminlib.php');
1ae083e4 30
fab6f7b7 31admin_externalpage_setup('toolreplace');
04337d75 32
61ef8f9f 33echo $OUTPUT->header();
04337d75 34
4387f138 35echo $OUTPUT->heading(get_string('pageheader', 'tool_replace'));
04337d75 36
6c3ae510 37if (!$DB->replace_all_text_supported()) {
4387f138 38 echo $OUTPUT->notification(get_string('notimplemented', 'tool_replace'));
c3b5e829
PS
39 echo $OUTPUT->footer();
40 die;
41}
c9a49cea 42
6c3ae510
PS
43echo $OUTPUT->box_start();
44echo $OUTPUT->notification(get_string('notsupported', 'tool_replace'));
45echo $OUTPUT->notification(get_string('excludedtables', 'tool_replace'));
46echo $OUTPUT->box_end();
47
48$form = new tool_replace_form();
04337d75 49
6c3ae510
PS
50if (!$data = $form->get_data()) {
51 $form->display();
73d6f52f 52 echo $OUTPUT->footer();
6c3ae510 53 die();
04337d75 54}
55
6c3ae510
PS
56// Scroll to the end when finished.
57$PAGE->requires->js_init_code("window.scrollTo(0, 5000000);");
58
8fbce1c8 59echo $OUTPUT->box_start();
6ced7617 60db_replace($data->search, $data->replace, $data->additionalskiptables);
8fbce1c8 61echo $OUTPUT->box_end();
04337d75 62
6c3ae510 63// Course caches are now rebuilt on the fly.
c9a49cea 64
fab6f7b7 65echo $OUTPUT->continue_button(new moodle_url('/admin/index.php'));
04337d75 66
73d6f52f 67echo $OUTPUT->footer();