2005-01-16 13:49:30 +00:00
|
|
|
<?php /// $Id$
|
|
|
|
/// Search and replace strings throughout all texts in the whole database
|
|
|
|
|
2006-03-06 19:27:25 +00:00
|
|
|
require_once('../config.php');
|
2006-09-25 20:22:55 +00:00
|
|
|
require_once($CFG->dirroot.'/course/lib.php');
|
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
2007-04-30 17:08:34 +00:00
|
|
|
|
|
|
|
admin_externalpage_setup('replace');
|
2005-01-16 13:49:30 +00:00
|
|
|
|
2006-03-06 19:27:25 +00:00
|
|
|
$search = optional_param('search', '', PARAM_RAW);
|
|
|
|
$replace = optional_param('replace', '', PARAM_RAW);
|
2005-01-16 13:49:30 +00:00
|
|
|
|
|
|
|
###################################################################
|
2007-04-30 17:08:34 +00:00
|
|
|
admin_externalpage_print_header();
|
2005-01-16 13:49:30 +00:00
|
|
|
|
2006-09-25 20:22:55 +00:00
|
|
|
print_heading('Search and replace text throughout the whole database');
|
2005-01-16 13:49:30 +00:00
|
|
|
|
2006-09-25 20:22:55 +00:00
|
|
|
|
|
|
|
if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Print a form
|
2005-01-16 13:49:30 +00:00
|
|
|
|
|
|
|
print_simple_box_start('center');
|
2008-12-10 06:48:54 +00:00
|
|
|
echo '<div class="mdl-align">';
|
2006-09-25 20:22:55 +00:00
|
|
|
echo '<form action="replace.php" method="post">';
|
2009-01-02 10:36:25 +00:00
|
|
|
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
2006-12-19 06:19:16 +00:00
|
|
|
echo 'Search whole database for: <input type="text" name="search" /><br />';
|
|
|
|
echo 'Replace with this string: <input type="text" name="replace" /><br />';
|
|
|
|
echo '<input type="submit" value="Yes, do it now" /><br />';
|
2005-01-16 13:49:30 +00:00
|
|
|
echo '</form>';
|
|
|
|
echo '</div>';
|
|
|
|
print_simple_box_end();
|
2007-04-30 17:08:34 +00:00
|
|
|
admin_externalpage_print_footer();
|
2005-01-16 13:49:30 +00:00
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_simple_box_start('center');
|
2006-09-25 20:22:55 +00:00
|
|
|
|
2008-05-30 21:36:57 +00:00
|
|
|
if (!db_replace($search, $replace)) {
|
2008-04-10 03:44:09 +00:00
|
|
|
print_error('erroroccur', debug);
|
2005-01-16 13:49:30 +00:00
|
|
|
}
|
2006-09-19 07:08:19 +00:00
|
|
|
|
2005-01-16 13:49:30 +00:00
|
|
|
print_simple_box_end();
|
|
|
|
|
2009-03-12 19:04:53 +00:00
|
|
|
/// Try to replace some well-known serialised contents (html blocks)
|
|
|
|
notify('Replacing in html blocks...');
|
2009-05-07 08:55:10 +00:00
|
|
|
$instances = $DB->get_recordset('block_instances', array('blockname' => 'html'));
|
|
|
|
foreach ($instances as $instance) {
|
|
|
|
$blockobject = block_instance('html', $instance);
|
|
|
|
$blockobject->config->text = str_replace($search, $replace, $blockobject->config->text);
|
|
|
|
$blockobject->instance_config_commit($blockobject->pinned);
|
2009-03-12 19:04:53 +00:00
|
|
|
}
|
2009-05-07 08:55:10 +00:00
|
|
|
$instances->close();
|
2009-03-12 19:04:53 +00:00
|
|
|
|
2006-09-25 20:22:55 +00:00
|
|
|
/// Rebuild course cache which might be incorrect now
|
2008-05-15 21:40:00 +00:00
|
|
|
notify('Rebuilding course cache...', 'notifysuccess');
|
2006-09-25 20:22:55 +00:00
|
|
|
rebuild_course_cache();
|
2008-05-15 21:40:00 +00:00
|
|
|
notify('...finished', 'notifysuccess');
|
2006-09-25 20:22:55 +00:00
|
|
|
|
2005-01-16 13:49:30 +00:00
|
|
|
print_continue('index.php');
|
|
|
|
|
2007-04-30 17:08:34 +00:00
|
|
|
admin_externalpage_print_footer();
|
2006-09-25 20:22:55 +00:00
|
|
|
|
2005-01-16 13:49:30 +00:00
|
|
|
?>
|