Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 39 and 311]

   1  <?php
   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   *
  20   * @package    tool_replace
  21   * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  define('NO_OUTPUT_BUFFERING', true);
  26  
  27  require_once('../../../config.php');
  28  require_once($CFG->dirroot.'/course/lib.php');
  29  require_once($CFG->libdir.'/adminlib.php');
  30  
  31  admin_externalpage_setup('toolreplace');
  32  
  33  echo $OUTPUT->header();
  34  
  35  echo $OUTPUT->heading(get_string('pageheader', 'tool_replace'));
  36  
  37  if (!$DB->replace_all_text_supported()) {
  38      echo $OUTPUT->notification(get_string('notimplemented', 'tool_replace'));
  39      echo $OUTPUT->footer();
  40      die;
  41  }
  42  
  43  echo $OUTPUT->box_start();
  44  echo $OUTPUT->notification(get_string('notsupported', 'tool_replace'));
  45  echo $OUTPUT->notification(get_string('excludedtables', 'tool_replace'));
  46  echo $OUTPUT->box_end();
  47  
  48  $form = new tool_replace_form();
  49  
  50  if (!$data = $form->get_data()) {
  51      $form->display();
  52      echo $OUTPUT->footer();
  53      die();
  54  }
  55  
  56  // Scroll to the end when finished.
  57  $PAGE->requires->js_init_code("window.scrollTo(0, 5000000);");
  58  
  59  echo $OUTPUT->box_start();
  60  db_replace($data->search, $data->replace, $data->additionalskiptables);
  61  echo $OUTPUT->box_end();
  62  
  63  // Course caches are now rebuilt on the fly.
  64  
  65  echo $OUTPUT->continue_button(new moodle_url('/admin/index.php'));
  66  
  67  echo $OUTPUT->footer();