Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
    $formatoptions = [
59
        'context' => $options['context'],
60
        'noclean' => $options['noclean'] ?? false,
61
        'trusted' => $options['trusted'] ?? false,
62
    ];
63
 
64
    $result = format_text($texexample, true, $formatoptions);
65
 
66
    $texfilteractive = ($texexample !== $result);
67
    $context = $options['context'];
68
 
69
    // Tex example librarys.
70
    $library = array(
71
            'group1' => array(
72
                'groupname' => 'librarygroup1',
73
                'elements' => get_config('atto_equation', 'librarygroup1'),
74
                'active' => true,
75
            ),
76
            'group2' => array(
77
                'groupname' => 'librarygroup2',
78
                'elements' => get_config('atto_equation', 'librarygroup2'),
79
            ),
80
            'group3' => array(
81
                'groupname' => 'librarygroup3',
82
                'elements' => get_config('atto_equation', 'librarygroup3'),
83
            ),
84
            'group4' => array(
85
                'groupname' => 'librarygroup4',
86
                'elements' => get_config('atto_equation', 'librarygroup4'),
87
            ));
88
 
89
    return array('texfilteractive' => $texfilteractive,
90
                 'contextid' => $context->id,
91
                 'library' => $library,
92
                 'texdocsurl' => get_docs_url('Using_TeX_Notation'));
93
}