Used to reformat the data from the editor component

@return stdClass
973843
function get_data() {
        $data = parent::get_data();

        if ($data !== null and isset($data->description)) {
            $data->descriptionformat = $data->description['format'];
            $data->description = $data->description['text'];
        }

        return $data;
    }
534922
function toHtml(){

        $id     = $this->_attributes['id'];
        $elname = $this->_attributes['name'];

        // Add the class at the last minute.
        if ($this->get_force_ltr()) {
            if (!isset($this->_attributes['class'])) {
                $this->_attributes['class'] = 'text-ltr';
            } else {
                $this->_attributes['class'] .= ' text-ltr';
            }
        }

        if ($this->_hiddenLabel) {
            $this->_generateId();
            $str = '<label class="accesshide" for="'.$this->getAttribute('id').'" >'.
                        $this->getLabel().'</label>'.parent::toHtml();
        } else {
            $str = parent::toHtml();
        }
        if (empty($this->_options['usefilepicker'])) {
            return $str;
        }

        // Print out file picker.
        $str .= $this->getFilePickerHTML();
        $str = '<div id="url-wrapper-' . $this->get_filepicker_unique_id() . '">' . $str . '</div>';

        return $str;
    }
991355
public function definition() {
        $mform = $this->_form;
        $instance = $this->_customdata;
        $dirtyclass = array('class' => 'ignoredirty');

        $mform->addElement('header', 'general', get_string('gradingoptions', 'assign'));
        // Visible elements.
        $options = array(-1 => get_string('all'), 10 => '10', 20 => '20', 50 => '50', 100 => '100');
        $maxperpage = get_config('assign', 'maxperpage');
        if (isset($maxperpage) && $maxperpage != -1) {
            unset($options[-1]);
            foreach ($options as $val) {
                if ($val > $maxperpage) {
                    unset($options[$val]);
                }
            }
        }
        $mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options, $dirtyclass);
        $options = array('' => get_string('filternone', 'assign'),
                         ASSIGN_FILTER_NOT_SUBMITTED => get_string('filternotsubmitted', 'assign'),
                         ASSIGN_FILTER_SUBMITTED => get_string('filtersubmitted', 'assign'),
                         ASSIGN_FILTER_REQUIRE_GRADING => get_string('filterrequiregrading', 'assign'),
                         ASSIGN_FILTER_GRANTED_EXTENSION => get_string('filtergrantedextension', 'assign'));
        if ($instance['submissionsenabled']) {
            $mform->addElement('select', 'filter', get_string('filter', 'assign'), $options, $dirtyclass);
        }
        if (!empty($instance['markingallocationopt'])) {
            $markingfilter = get_string('markerfilter', 'assign');
            $mform->addElement('select', 'markerfilter', $markingfilter, $instance['markingallocationopt'], $dirtyclass);
        }
        if (!empty($instance['markingworkflowopt'])) {
            $workflowfilter = get_string('workflowfilter', 'assign');
            $mform->addElement('select', 'workflowfilter', $workflowfilter, $instance['markingworkflowopt'], $dirtyclass);
        }
        // Quickgrading.
        if ($instance['showquickgrading']) {
            $mform->addElement('checkbox', 'quickgrading', get_string('quickgrading', 'assign'), '', $dirtyclass);
            $mform->addHelpButton('quickgrading', 'quickgrading', 'assign');
            $mform->setDefault('quickgrading', $instance['quickgrading']);
        }

        // Show active/suspended user option.
        if ($instance['showonlyactiveenrolopt']) {
            $mform->addElement('checkbox', 'showonlyactiveenrol', get_string('showonlyactiveenrol', 'grades'), '', $dirtyclass);
            $mform->addHelpButton('showonlyactiveenrol', 'showonlyactiveenrol', 'grades');
            $mform->setDefault('showonlyactiveenrol', $instance['showonlyactiveenrol']);
        }

        // Place student downloads in seperate folders.
        if ($instance['submissionsenabled']) {
            $mform->addElement('checkbox', 'downloadasfolders', get_string('downloadasfolders', 'assign'), '', $dirtyclass);
            $mform->addHelpButton('downloadasfolders', 'downloadasfolders', 'assign');
            $mform->setDefault('downloadasfolders', $instance['downloadasfolders']);
        }

        // Hidden params.
        $mform->addElement('hidden', 'contextid', $instance['contextid']);
        $mform->setType('contextid', PARAM_INT);
        $mform->addElement('hidden', 'id', $instance['cm']);
        $mform->setType('id', PARAM_INT);
        $mform->addElement('hidden', 'userid', $instance['userid']);
        $mform->setType('userid', PARAM_INT);
        $mform->addElement('hidden', 'action', 'saveoptions');
        $mform->setType('action', PARAM_ALPHA);

        // Buttons.
        $this->add_action_buttons(false, get_string('updatetable', 'assign'));
    }
1250866
public function EditorToolbar() {
		// todo(jake): move into MultiRecordField as extension?
		if (!HtmlEditorConfig::get_active()->getOption('language')) {
			HtmlEditorConfig::get_active()->setOption('language', i18n::get_tinymce_lang());
		}
		return HtmlEditorField_Toolbar::create($this, __FUNCTION__);
	}
1214739
public function format() {

        /*         * Add the mandatary props* */
        if (!is_null($this->name)) {
            $result[self::NAME_KEY] = $this->name;
        }

        /*         * Add the optional props if any* */
        if (!is_null($this->optionalProperties)) {
            $result = array_merge($result, $this->optionalProperties);
        }


        return $result;
    }
708013
public function getFormattedData()
    {
        $decodedContent = $this->jsonDecode();

        $processedData = [];

        foreach ($decodedContent['table']['rows'] as $row) {
            foreach($decodedContent['table']['cols'] as $key => $col) {
                $processedData[$col['label']][] = $row['c'][$key]['v'];
            }
        }

        return $processedData;
    }
783071
protected function getAddonCssClass()
	{
		$classes = array();
		if (isset($this->prependText))
			$classes[] = 'input-prepend';
		if (isset($this->appendText))
			$classes[] = 'input-append';

		return implode(' ', $classes);
	}
1187525
public function definition () {
        global $CFG, $COURSE, $USER;

        $mform = $this->_form;
        $editoroptions = null;
        $filemanageroptions = null;
        $usernotfullysetup = user_not_fully_set_up($USER);

        if (!is_array($this->_customdata)) {
            throw new coding_exception('invalid custom data for user_edit_form');
        }
        $editoroptions = $this->_customdata['editoroptions'];
        $filemanageroptions = $this->_customdata['filemanageroptions'];
        $user = $this->_customdata['user'];
        $userid = $user->id;

        if (empty($user->country)) {
            // We must unset the value here so $CFG->country can be used as default one.
            unset($user->country);
        }

        // Accessibility: "Required" is bad legend text.
        $strgeneral  = get_string('general');
        $strrequired = get_string('required');

        // Add some extra hidden fields.
        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        $mform->addElement('hidden', 'course', $COURSE->id);
        $mform->setType('course', PARAM_INT);

        // Print the required moodle fields first.
        $mform->addElement('header', 'moodle', $strgeneral);

        // Shared fields.
        useredit_shared_definition($mform, $editoroptions, $filemanageroptions, $user);

        // Extra settigs.
        if (!empty($CFG->disableuserimages) || $usernotfullysetup) {
            $mform->removeElement('deletepicture');
            $mform->removeElement('imagefile');
            $mform->removeElement('imagealt');
        }

        // If the user isn't fully set up, let them know that they will be able to change
        // their profile picture once their profile is complete.
        if ($usernotfullysetup) {
            $userpicturewarning = $mform->createElement('warning', 'userpicturewarning', 'notifymessage', get_string('newpictureusernotsetup'));
            $enabledusernamefields = useredit_get_enabled_name_fields();
            if ($mform->elementExists('moodle_additional_names')) {
                $mform->insertElementBefore($userpicturewarning, 'moodle_additional_names');
            } else if ($mform->elementExists('moodle_interests')) {
                $mform->insertElementBefore($userpicturewarning, 'moodle_interests');
            } else {
                $mform->insertElementBefore($userpicturewarning, 'moodle_optional');
            }

            // This is expected to exist when the form is submitted.
            $imagefile = $mform->createElement('hidden', 'imagefile');
            $mform->insertElementBefore($imagefile, 'userpicturewarning');
        }

        // Next the customisable profile fields.
        profile_definition($mform, $userid);

        $this->add_action_buttons(true, get_string('updatemyprofile'));

        $this->set_data($user);
    }
513234
public function getData() : \stdClass
    {
        $output = new \stdClass();

        foreach ($this->data as $key => $property) {
            if ($this->options['lowercase']) {
                $key = strtolower($key);
            }

            $output->{$key} = $property;
        }

        return $output;
    }
935427
public function getEditorConfig()
    {
        // Instance override
        if ($this->editorConfig instanceof HTMLEditorConfig) {
            return $this->editorConfig;
        }

        // Get named / active config
        return HTMLEditorConfig::get($this->editorConfig);
    }
629918
protected function getEditorCSS()
    {
        $editor = [];
        $resourceLoader = ModuleResourceLoader::singleton();
        foreach ($this->getContentCSS() as $contentCSS) {
            $editor[] = $resourceLoader->resolveURL($contentCSS);
        }
        return $editor;
    }
513948
protected function formatJSON()
    {
        $result = new \stdClass;

        if ($this->outputMode == self::MODE_ERROR) {
            $this->formatFailure($result);
        } else {
            $this->formatSuccess($result);
        }

        // only include if it has valid data
        if ($this->meta) {
            $result->meta = $this->meta;
        }

        return $result;
    }
277204
public function getDataRowHTML()
    {
        $output = [];
        foreach ($this->columns as $name => $column) {

            // If multiple formatters are defined, use the first for the header cell

            if (!is_int($name)) {
                $field = $this->model->getElement($name);
            } else {
                $field = null;
            }

            if (!is_array($column)) {
                $column = [$column];
            }

            // we need to smartly wrap things up
            $cell = null;
            $cnt = count($column);
            $td_attr = [];
            foreach ($column as $c) {
                if (--$cnt) {
                    $html = $c->getDataCellTemplate($field);
                    $td_attr = $c->getTagAttributes('body', $td_attr);
                } else {
                    // Last formatter, ask it to give us whole rendering
                    $html = $c->getDataCellHTML($field, $td_attr);
                }

                if ($cell) {
                    if ($name) {
                        // if name is set, we can wrap things
                        $cell = str_replace('{$'.$name.'}', $cell, $html);
                    } else {
                        $cell = $cell.' '.$html;
                    }
                } else {
                    $cell = $html;
                }
            }

            $output[] = $cell;
        }

        return implode('', $output);
    }
980133
public function Render()
    {
        $string = $this->string;
        $tag = $this->tag;

        $classes = $this->classes;
        if (Count($classes)) {
            if ($classPrefix = $this->classPrefix) {
                foreach ($classes as $key => $value) {
                    $prefixedClass = $classPrefix . '__' . $value;
                    $classes[$prefixedClass] = $prefixedClass;
                }
            }
            $this->addAttribute('class', implode(' ', $classes));
        }

        if ($this->isVoidElement() && $string) {
            if ($voidAttributeName = $this->VoidElements[$tag]) {
                $this->addAttribute($voidAttributeName, $string);
            } else {
                throw new InvalidArgumentException("Void element \"{$tag}\" cannot have string");
            }
        }

        $attributes = [];
        foreach ($this->attributes as $name => $value) {
            $attributes[] = sprintf(
                '%s="%s"',
                $name,
                Convert::raw2att($value)
            );
        }
        $attributes = Count($attributes) ? ' ' . implode(' ', $attributes) : '';

        if ($this->isVoidElement()) {
            return "<{$tag}{$attributes} />";
        }

        if (!isset($string) || !$string || $string == '') {
            return null;
        }

        return "<{$tag}{$attributes}>{$string}</{$tag}>";
    }
155814
public function getEditor()
    {
        $user = null;

        if($this->hasProperty('modified_by') && !empty($this->modified_by)) {
            $user = $this->getObject('user.provider')->getUser($this->modified_by);
        }

        return $user;
    }
897049
public function definition () {
        global $CFG, $COURSE;

        $mform = $this->_form;

        $editors = editors_get_enabled();

        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        if (count($editors) > 1) {
            $choices = array('' => get_string('defaulteditor'));
            $firsteditor = '';
            foreach (array_keys($editors) as $editor) {
                if (!$firsteditor) {
                    $firsteditor = $editor;
                }
                $choices[$editor] = get_string('pluginname', 'editor_' . $editor);
            }
            $mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
            $mform->addHelpButton('preference_htmleditor', 'textediting');
            $mform->setDefault('preference_htmleditor', '');
        } else {
            // Empty string means use the first chosen text editor.
            $mform->addElement('hidden', 'preference_htmleditor');
            $mform->setDefault('preference_htmleditor', '');
            $mform->setType('preference_htmleditor', PARAM_PLUGIN);
        }

        $this->add_action_buttons(true, get_string('savechanges'));
    }
272026
public function definition() {
        $mform = $this->_form;

        $handler = $this->_customdata['handler'];

        // Set up the options for formatting text for descriptions, etc.
        $formatoptions = new stdClass();
        $formatoptions->trusted = false;
        $formatoptions->noclean = false;
        $formatoptions->smiley = false;
        $formatoptions->filter = false;
        $formatoptions->para = true;
        $formatoptions->newlines = false;
        $formatoptions->overflowdiv = true;

        // General information about the handler.
        $mform->addElement('header', 'general', get_string('general'));
        $mform->addElement('static', 'name', get_string('name', 'tool_messageinbound'),
            $handler->name);
        $mform->addElement('static', 'classname', get_string('classname', 'tool_messageinbound'));

        $description = format_text($handler->description, FORMAT_MARKDOWN, $formatoptions);

        $mform->addElement('static', 'description', get_string('description', 'tool_messageinbound'),
            $description);

        // Items which can be configured.
        $mform->addElement('header', 'configuration', get_string('configuration'));

        if ($handler->can_change_defaultexpiration()) {
            // Show option to change expiry only if the handler supports it.
            $options = array(
                HOURSECS => get_string('onehour', 'tool_messageinbound'),
                DAYSECS => get_string('oneday', 'tool_messageinbound'),
                WEEKSECS => get_string('oneweek', 'tool_messageinbound'),
                YEARSECS => get_string('oneyear', 'tool_messageinbound'),
                0 => get_string('noexpiry', 'tool_messageinbound'),
            );
            $mform->addElement('select', 'defaultexpiration', get_string('defaultexpiration', 'tool_messageinbound'), $options);
            $mform->addHelpButton('defaultexpiration', 'defaultexpiration', 'tool_messageinbound');
        } else {
            $text = $this->get_defaultexpiration_text($handler);
            $mform->addElement('static', 'defaultexpiration_fake', get_string('defaultexpiration', 'tool_messageinbound'), $text);
            $mform->addElement('hidden', 'defaultexpiration');
            $mform->addHelpButton('defaultexpiration_fake', 'defaultexpiration', 'tool_messageinbound');
            $mform->setType('defaultexpiration', PARAM_INT);
        }

        if ($handler->can_change_validateaddress()) {
            $mform->addElement('checkbox', 'validateaddress', get_string('requirevalidation', 'tool_messageinbound'));
            $mform->addHelpButton('validateaddress', 'validateaddress', 'tool_messageinbound');
        } else {
            if ($handler->validateaddress) {
                $text = get_string('yes');
            } else {
                $text = get_string('no');
            }
            $mform->addElement('static', 'validateaddress_fake', get_string('requirevalidation', 'tool_messageinbound'), $text);
            $mform->addElement('hidden', 'validateaddress');
            $mform->addHelpButton('validateaddress_fake', 'fixedvalidateaddress', 'tool_messageinbound');
            $mform->setType('validateaddress', PARAM_INT);
        }

        if ($handler->can_change_enabled()) {
            $mform->addElement('checkbox', 'enabled', get_string('enabled', 'tool_messageinbound'));
        } else {
            if ($handler->enabled) {
                $text = get_string('yes');
            } else {
                $text = get_string('no');
            }
            $mform->addElement('static', 'enabled_fake', get_string('enabled', 'tool_messageinbound'), $text);
            $mform->addHelpButton('enabled', 'fixedenabled', 'tool_messageinbound');
            $mform->addElement('hidden', 'enabled');
            $mform->setType('enabled', PARAM_INT);
        }

        $this->add_action_buttons(true, get_string('savechanges'));
    }