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
 * Demonstrates use of Atto editor with overridden toolbar setting.
19
 *
20
 * This fixture is only used by the Behat test.
21
 *
22
 * @package editor_atto
23
 * @copyright 2016 The Open University
24
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
 
27
require(__DIR__ . '/../../../../../config.php');
28
require_once($CFG->dirroot . '/lib/editor/atto/lib.php');
29
 
30
// Behat test fixture only.
31
defined('BEHAT_SITE_RUNNING') || die('Only available on Behat test server');
32
 
33
$PAGE->set_url('/lib/editor/atto/tests/fixtures/override_plugins_example.php');
34
$PAGE->set_context(context_system::instance());
35
 
36
echo $OUTPUT->header();
37
 
38
// If this was sending some input, display it.
39
$normal = optional_param('normaleditor', '', PARAM_RAW);
40
$special = optional_param('specialeditor', '', PARAM_RAW);
41
if ($normal !== '' || $special !== '') {
42
    echo html_writer::start_div('normalresult');
43
    echo s($normal);
44
    echo html_writer::end_div();
45
    echo html_writer::start_div('specialresult');
46
    echo s($special);
47
    echo html_writer::end_div();
48
} else {
49
    // Create a form.
50
    echo html_writer::start_tag('form', array('method' => 'post', 'action' => 'custom_toolbar_example.php'));
51
    echo html_writer::start_div();
52
 
53
    // Basic editor options.
54
    $options = array();
55
    $atto = new atto_texteditor();
56
 
57
    // Normal Atto.
58
    echo html_writer::start_div('normaldiv');
59
    echo $OUTPUT->heading('Normal Atto');
60
    echo html_writer::div(html_writer::tag('textarea', '',
61
            array('id' => 'normaleditor', 'name' => 'normaleditor', 'rows' => 10)));
62
    $atto->use_editor('normaleditor', $options);
63
    echo html_writer::end_div();
64
 
65
    // Second Atto with custom options.
66
    echo html_writer::start_div('specialdiv');
67
    $options['atto:toolbar'] = <<<EOT
68
style1 = bold, italic
69
list = unorderedlist, orderedlist
70
EOT;
71
    echo $OUTPUT->heading('Special Atto');
72
    echo html_writer::div(html_writer::tag('textarea', '',
73
            array('id' => 'specialeditor', 'name' => 'specialeditor', 'rows' => 10)));
74
    $atto->use_editor('specialeditor', $options);
75
    echo html_writer::end_div();
76
 
77
    // Button to submit form.
78
    echo html_writer::start_div('', array('style' => 'margin-top: 20px'));
79
    echo html_writer::tag('button', 'Submit and see the HTML');
80
    echo html_writer::end_div();
81
 
82
    echo html_writer::end_div();
83
    echo html_writer::end_tag('form');
84
}
85
 
86
echo $OUTPUT->footer();