Stripped down Atto editor

Stripped down Atto editor

από Frederic Nevers -
Αριθμός απαντήσεων: 4

Hi, 

I am creating a form in a local plugin, in which I would like to only allow teachers to use bullet point and numbered lists on the Atto editor. I have looked at the Forms API but I cannot find a way to disable Atto plugins for this one form only. I have attached a mockup of what I am after. The only thing I have been able to do is to disable the file uploads.

Am I looking at the wrong place? Has anyone done this before, or can think of examples within the Moodle codebase (or third-party plugins) I could look at? Is it simply impossible without getting a major headache?

Cheers, 

Fred


Μέσος όρος βαθμολογίας: -
Σε απάντηση σε Frederic Nevers

Re: Stripped down Atto editor

από Paul Holden -
Φωτογραφία Core developers Φωτογραφία Moodle HQ Φωτογραφία Moodle Workplace team Φωτογραφία Particularly helpful Moodlers Φωτογραφία Peer reviewers Φωτογραφία Plugin developers Φωτογραφία Testers
Σε απάντηση σε Paul Holden

Re: Stripped down Atto editor

από Frederic Nevers -

Thanks a lot for the link, Paul. I am struggling to get things going, as there is no documentation. 

Here is what I have so far, which does not work (i.e. all of the Atto icons are displayed).

$editoroptions = array(
'maxfiles' => 0,
'maxbytes' => 0,
'trusttext' => false,
'noclean' => false,
'context' => $context,
'subdirs' => 0,
'atto:toolbar' => 'style1 = bold, italic'
);

Has anyone implemented this successfully? Am I placing the atto options in the wrong place?

Cheers, 

Fred

Σε απάντηση σε Frederic Nevers

Re: Stripped down Atto editor

από Peter Spicer -

Hi,

Might be a late reply, but if you're trying to use this inside a regular moodleform instance somewhere, it won't work because of a bug in Moodle - https://tracker.moodle.org/projects/MDL/issues/MDL-59904

As I said in the ticket, I created a new class in my plugin called MoodleQuickForm_simpleeditor, saved as mod/myplugin/simpleeditor.php (not the real path, but one for example uses):

class MoodleQuickForm_simpleeditor extends MoodleQuickForm_editor {
    public function __construct($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
        $this->_options['atto:toolbar'] = '';
        parent::__construct($elementName, $elementLabel, $attributes, $options);
    }
}

Then in my form definition I have:

    public function definition() {
        global $CFG;

        // Load the files we're going to need.
        require_once("$CFG->libdir/form/editor.php");
        require_once("$CFG->dirroot/mod/myplugin/simpleeditor.php");

        $mform = $this->_form;
        require_once("$CFG->libdir/form/editor.php");
        \MoodleQuickForm::registerElementType('simpleeditor', "$CFG->libdir/form/editor.php", 'MoodleQuickForm_simpleeditor');

        $editoroptions = array(
            'subdirs' => 0,
            'maxbytes' => 0,
            'maxfiles' => 0,
            'changeformat' => 0,
            'context' => null,
            'noclean' => 0,
            'trusttext' => 0,
            'enable_filemanagement' => false,
            'atto:toolbar' => 'style1 = bold, italic',
        );
        $mform->addElement('simpleeditor', 'mytextfield', null, null, $editoroptions);
        $mform->setType('mytextfield', PARAM_RAW);
    }

(My editor doesn't have a text label on it, but that's because I wanted it to be that way. You'd put the text label in place of the first null there.)

Hope this helps,

Peter