[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/filter/mathjaxloader/db/ -> upgrade.php (source)

   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   * MathJAX filter upgrade code.
  19   *
  20   * @package    filter_mathjaxloader
  21   * @copyright  2014 Damyon Wiese (damyon@moodle.com)
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * @param int $oldversion the version we are upgrading from
  29   * @return bool result
  30   */
  31  function xmldb_filter_mathjaxloader_upgrade($oldversion) {
  32      global $CFG, $DB;
  33  
  34      $dbman = $DB->get_manager();
  35  
  36      if ($oldversion < 2014081100) {
  37  
  38          $sslcdnurl = get_config('filter_mathjaxloader', 'httpsurl');
  39          if ($sslcdnurl === "https://c328740.ssl.cf1.rackcdn.com/mathjax/2.3-latest/MathJax.js") {
  40              set_config('httpsurl', 'https://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js', 'filter_mathjaxloader');
  41          }
  42  
  43          upgrade_plugin_savepoint(true, 2014081100, 'filter', 'mathjaxloader');
  44      }
  45  
  46      // Moodle v2.8.0 release upgrade line.
  47      // Put any upgrade step following this.
  48  
  49      if ($oldversion < 2015021200) {
  50  
  51          $httpurl = get_config('filter_mathjaxloader', 'httpurl');
  52          // Don't change the config if it has been manually changed to something besides the default setting value.
  53          if ($httpurl === "http://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js") {
  54              set_config('httpurl', 'http://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js', 'filter_mathjaxloader');
  55          }
  56  
  57          $httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
  58          // Don't change the config if it has been manually changed to something besides the default setting value.
  59          if ($httpsurl === "https://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js") {
  60              set_config('httpsurl', 'https://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js', 'filter_mathjaxloader');
  61          }
  62  
  63          upgrade_plugin_savepoint(true, 2015021200, 'filter', 'mathjaxloader');
  64      }
  65  
  66      if ($oldversion < 2015021700) {
  67  
  68          $oldconfig = get_config('filter_mathjaxloader', 'mathjaxconfig');
  69          $olddefault = 'MathJax.Hub.Config({
  70      config: ["MMLorHTML.js", "Safe.js"],
  71      jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML"],
  72      extensions: ["tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js"],
  73      TeX: {
  74          extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"]
  75      },
  76      menuSettings: {
  77          zoom: "Double-Click",
  78          mpContext: true,
  79          mpMouse: true
  80      },
  81      errorSettings: { message: ["!"] },
  82      skipStartupTypeset: true,
  83      messageStyle: "none"
  84  });
  85  ';
  86          $newdefault = '
  87  MathJax.Hub.Config({
  88      config: ["Accessible.js", "Safe.js"],
  89      errorSettings: { message: ["!"] },
  90      skipStartupTypeset: true,
  91      messageStyle: "none"
  92  });
  93  ';
  94  
  95          // Ignore white space changes.
  96          $oldconfig = trim(preg_replace('/\s+/', ' ', $oldconfig));
  97          $olddefault = trim(preg_replace('/\s+/', ' ', $olddefault));
  98  
  99          // Update the default config for mathjax only if it has not been customised.
 100  
 101          if ($oldconfig == $olddefault) {
 102              set_config('mathjaxconfig', $newdefault, 'filter_mathjaxloader');
 103          }
 104  
 105          upgrade_plugin_savepoint(true, 2015021700, 'filter', 'mathjaxloader');
 106      }
 107  
 108      // Moodle v2.9.0 release upgrade line.
 109      // Put any upgrade step following this.
 110  
 111      // Moodle v3.0.0 release upgrade line.
 112      // Put any upgrade step following this.
 113  
 114      // Moodle v3.1.0 release upgrade line.
 115      // Put any upgrade step following this.
 116  
 117      if ($oldversion < 2016032200) {
 118  
 119          $httpurl = get_config('filter_mathjaxloader', 'httpurl');
 120          // Don't change the config if it has been manually changed to something besides the default setting value.
 121          if ($httpurl === "http://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js") {
 122              set_config('httpurl', 'http://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js', 'filter_mathjaxloader');
 123          }
 124  
 125          $httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
 126          // Don't change the config if it has been manually changed to something besides the default setting value.
 127          if ($httpsurl === "https://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js") {
 128              set_config('httpsurl', 'https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js', 'filter_mathjaxloader');
 129          }
 130  
 131          upgrade_plugin_savepoint(true, 2016032200, 'filter', 'mathjaxloader');
 132      }
 133  
 134      return true;
 135  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1