Skip to content

Commit

Permalink
MDL-43842: Import atto back into core
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Mar 26, 2014
1 parent 46c627c commit adca732
Show file tree
Hide file tree
Showing 350 changed files with 12,326 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/classes/plugin_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,11 @@ public static function standard_plugins_list($type) {

$standard_plugins = array(

'atto' => array(
'bold', 'html', 'indent', 'link', 'orderedlist', 'strike', 'title', 'unlink',
'clear', 'image', 'italic', 'media', 'outdent', 'table', 'underline', 'unorderedlist'
),

'assignment' => array(
'offline', 'online', 'upload', 'uploadsingle'
),
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/plugininfo/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function get_enabled_plugins() {
global $CFG;

if (empty($CFG->texteditors)) {
return array('tinymce'=>'tinymce', 'textarea'=>'textarea');
return array('atto'=>'atto', 'tinymce'=>'tinymce', 'textarea'=>'textarea');
}

$enabled = array();
Expand Down
674 changes: 674 additions & 0 deletions lib/editor/atto/LICENSE

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions lib/editor/atto/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Small, fast, accessible, mobile friendly text editor for Moodle

QUICK INSTALL
=============
Put this entire directory at:

PATHTOMOODLE/lib/editors/atto

Visit your site notifications page to install the new plugins.

Enable the new editor on the page:

Site administration / ► Plugins / ► Text editors / ► Manage editors

To make it the default, change the order so this editor is the first in the list.

In Moodle 2.6 users can also choose this editor from their profile preferences.

35 changes: 35 additions & 0 deletions lib/editor/atto/classes/plugininfo/atto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Subplugin info class.
*
* @package editor_atto
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace editor_atto\plugininfo;

use core\plugininfo\base;

defined('MOODLE_INTERNAL') || die();


class atto extends base {
public function is_uninstall_allowed() {
return true;
}
}
49 changes: 49 additions & 0 deletions lib/editor/atto/db/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Atto text editor installation steps.
*
* @package editor_atto
* @copyright 2013 Damyon Wiese <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Enable this text editor by default.
*
* @return bool
*/
function xmldb_editor_atto_install() {
global $CFG;
// Get the current list of editors.
$currentconfig = $CFG->texteditors;
if (is_null($currentconfig)) {
$currentconfig = '';
}
$editors = explode(',', $currentconfig);
// Insert atto in the second position.
array_splice($editors, 1, 0, array('atto'));
// Remove duplicates.
$editors = array_unique($editors);
// Set the new config.
unset_config('texteditors');
set_config('texteditors', implode(',', $editors));

return true;
}
27 changes: 27 additions & 0 deletions lib/editor/atto/db/subplugins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Yui Editor
*
* @package editor_atto
* @copyright 2013 Damyon Wiese <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$subplugins = array('atto' => 'lib/editor/atto/plugins');
25 changes: 25 additions & 0 deletions lib/editor/atto/lang/en/editor_atto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Strings for component 'editor_atto', language 'en'.
*
* @package editor_atto
* @copyright 2013 Damyon Wiese <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['pluginname'] = 'Atto HTML editor';
124 changes: 124 additions & 0 deletions lib/editor/atto/lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* YUI text editor integration.
*
* @package editor_atto
* @copyright 2013 Damyon Wiese <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* This is the texteditor implementation.
* @copyright 2013 Damyon Wiese <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class atto_texteditor extends texteditor {

/**
* Is the current browser supported by this editor?
*
* Of course!
* @return bool
*/
public function supported_by_browser() {
return true;
}

/**
* Returns array of supported text formats.
* @return array
*/
public function get_supported_formats() {
// FORMAT_MOODLE is not supported here, sorry.
return array(FORMAT_HTML => FORMAT_HTML);
}

/**
* Returns text format preferred by this editor.
* @return int
*/
public function get_preferred_format() {
return FORMAT_HTML;
}

/**
* Does this editor support picking from repositories?
* @return bool
*/
public function supports_repositories() {
return true;
}

/**
* Use this editor for give element.
*
* @param string $elementid
* @param array $options
* @param null $fpoptions
*/
public function use_editor($elementid, array $options=null, $fpoptions=null) {
global $PAGE;
$PAGE->requires->yui_module('moodle-editor_atto-editor',
'M.editor_atto.init',
array($this->get_init_params($elementid, $options, $fpoptions)));

$plugins = core_component::get_plugin_list('atto');

foreach ($plugins as $name => $fulldir) {
$PAGE->requires->string_for_js('pluginname', 'atto_' . $name);
$plugins[$name] = component_callback('atto_' . $name, 'sort_order', array($elementid));
}

asort($plugins);
foreach ($plugins as $name => $sort) {
component_callback('atto_' . $name, 'init_editor', array($elementid));
}

}

/**
* Create a params array to init the editor.
*
* @param string $elementid
* @param array $options
* @param array $fpoptions
*/
protected function get_init_params($elementid, array $options=null, array $fpoptions=null) {
global $PAGE;

$directionality = get_string('thisdirection', 'langconfig');
$strtime = get_string('strftimetime');
$strdate = get_string('strftimedaydate');
$lang = current_language();
$contentcss = $PAGE->theme->editor_css_url()->out(false);

$params = array(
'elementid' => $elementid,
'content_css' => $contentcss,
'language' => $lang,
'directionality' => $directionality,
'filepickeroptions' => array()
);
if ($fpoptions) {
$params['filepickeroptions'] = $fpoptions;
}
return $params;
}
}
Binary file added lib/editor/atto/pix/e/abbr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions lib/editor/atto/pix/e/abbr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/editor/atto/pix/e/absolute.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions lib/editor/atto/pix/e/absolute.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/editor/atto/pix/e/acronym.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions lib/editor/atto/pix/e/acronym.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/editor/atto/pix/e/advance_hr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions lib/editor/atto/pix/e/advance_hr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/editor/atto/pix/e/align_center.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions lib/editor/atto/pix/e/align_center.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lib/editor/atto/pix/e/align_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit adca732

Please sign in to comment.