2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * YUI text editor integration.
20 * @package editor_atto
21 * @copyright 2013 Damyon Wiese <damyon@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
28 * This is the texteditor implementation.
29 * @copyright 2013 Damyon Wiese <damyon@moodle.com>
30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 class atto_texteditor extends texteditor {
35 * Is the current browser supported by this editor?
40 public function supported_by_browser() {
45 * Returns array of supported text formats.
48 public function get_supported_formats() {
49 // FORMAT_MOODLE is not supported here, sorry.
50 return array(FORMAT_HTML => FORMAT_HTML);
54 * Returns text format preferred by this editor.
57 public function get_preferred_format() {
62 * Does this editor support picking from repositories?
65 public function supports_repositories() {
70 * Use this editor for give element.
72 * @param string $elementid
73 * @param array $options
74 * @param null $fpoptions
76 public function use_editor($elementid, array $options=null, $fpoptions=null) {
78 $PAGE->requires->yui_module('moodle-editor_atto-editor',
80 array($this->get_init_params($elementid, $options, $fpoptions)), true);
82 $plugins = core_component::get_plugin_list('atto');
84 foreach ($plugins as $name => $fulldir) {
85 $plugins[$name] = component_callback('atto_' . $name, 'sort_order', array($elementid));
89 foreach ($plugins as $name => $sort) {
90 component_callback('atto_' . $name, 'init_editor', array($elementid));
96 * Create a params array to init the editor.
98 * @param string $elementid
99 * @param array $options
100 * @param array $fpoptions
102 protected function get_init_params($elementid, array $options=null, array $fpoptions=null) {
105 $directionality = get_string('thisdirection', 'langconfig');
106 $strtime = get_string('strftimetime');
107 $strdate = get_string('strftimedaydate');
108 $lang = current_language();
109 $contentcss = $PAGE->theme->editor_css_url()->out(false);
112 'elementid' => $elementid,
113 'content_css' => $contentcss,
115 'directionality' => $directionality,
116 'filepickeroptions' => array()
119 $params['filepickeroptions'] = $fpoptions;