Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 39 and 400]

   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   * Atto text editor integration version file.
  19   *
  20   * @package    atto_equation
  21   * @copyright  2013 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   * Get the list of strings for this plugin.
  29   * @param string $elementid
  30   */
  31  function atto_equation_strings_for_js() {
  32      global $PAGE;
  33  
  34      $PAGE->requires->strings_for_js(array('saveequation',
  35                                            'editequation',
  36                                            'preview',
  37                                            'cursorinfo',
  38                                            'update',
  39                                            'librarygroup1',
  40                                            'librarygroup2',
  41                                            'librarygroup3',
  42                                            'librarygroup4'),
  43                                      'atto_equation');
  44  }
  45  
  46  /**
  47   * Set params for this plugin.
  48   *
  49   * @param string $elementid
  50   * @param stdClass $options - the options for the editor, including the context.
  51   * @param stdClass $fpoptions - unused.
  52   */
  53  function atto_equation_params_for_js($elementid, $options, $fpoptions) {
  54      $texexample = '$$\pi$$';
  55  
  56      // Format a string with the active filter set.
  57      // If it is modified - we assume that some sort of text filter is working in this context.
  58      $result = format_text($texexample, true, $options);
  59  
  60      $texfilteractive = ($texexample !== $result);
  61      $context = $options['context'];
  62      if (!$context) {
  63          $context = context_system::instance();
  64      }
  65  
  66      // Tex example librarys.
  67      $library = array(
  68              'group1' => array(
  69                  'groupname' => 'librarygroup1',
  70                  'elements' => get_config('atto_equation', 'librarygroup1'),
  71                  'active' => true,
  72              ),
  73              'group2' => array(
  74                  'groupname' => 'librarygroup2',
  75                  'elements' => get_config('atto_equation', 'librarygroup2'),
  76              ),
  77              'group3' => array(
  78                  'groupname' => 'librarygroup3',
  79                  'elements' => get_config('atto_equation', 'librarygroup3'),
  80              ),
  81              'group4' => array(
  82                  'groupname' => 'librarygroup4',
  83                  'elements' => get_config('atto_equation', 'librarygroup4'),
  84              ));
  85  
  86      return array('texfilteractive' => $texfilteractive,
  87                   'contextid' => $context->id,
  88                   'library' => $library,
  89                   'texdocsurl' => get_docs_url('Using_TeX_Notation'));
  90  }